erste Versuche Python / Plotly

This commit is contained in:
Daniel Schick 2022-01-15 18:56:53 +01:00
parent cdb4f3f12c
commit eef1b0bcba
6 changed files with 15642 additions and 0 deletions

13
ReadMe.md Normal file
View File

@ -0,0 +1,13 @@
# Manöverdaten Auswertung
___
## Installation
`pip install plotly`
## Dokumentation
https://www.geeksforgeeks.org/python-plotly-tutorial/

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

65
tachymeter.py Normal file
View File

@ -0,0 +1,65 @@
import csv, sys
from lib2to3.pgen2.pgen import DFAState
import plotly.express as px
import plotly.io as pio
import plotly.graph_objects as go
filename = 'example_data/TachymeterTable_103.csv'
# einfaches Beispiel: CSV direkt ausgeben:
#with open(filename, newline='') as f:
# reader = csv.reader(f)
# try:
# for row in reader:
# print(row)
# except csv.Error as e:
# sys.exit('file {}, line {}: {}'.format(filename, reader.line_num, e))
# Time,x,y,z,d,deltaT,SOG,RelTime,Beschleunigung,BeschleunigungDeltaTFix,ABSBeschleunigung
class Tachymeter(object):
def __init__(self, i, x, y, z, d, deltaT, SOG, RelTime, Beschleunigung, BeschleunigungDeltaTFix, ABSBeschleunigung):
self.index = i
self.x = x
self.y = y
self.z = z
self.d = d
self.deltaT = deltaT
self.SOG = SOG
self.RelTime = RelTime
self.Beschleunigung = Beschleunigung
self.BeschleunigungDeltaTFix = BeschleunigungDeltaTFix
self.ABSBeschleunigung = ABSBeschleunigung
def __init__(self, row, header):
self.__dict__ = dict(zip(header, row))
self.index = row
data = list(csv.reader(open(filename, newline='')))
tachies = [Tachymeter(i, data[0]) for i in data[1:]]
# for tachy in tachies:
# print(tachy.x)
fig = dict({
"data": [{"type": "bar",
"x": [1, 2, 3],
"y": [1, 3, 2]}],
"layout": {"title": {"text": "A Figure Specified By Python Dictionary"}}
})
# pio.show(fig)
# fig = px.line(tachies, x="x", y="x", title="Tachymeter Daten x, y")
# fig.show()
df = dict( {
"x" : [ 1, 2, 3, 4, 5],
"y" : [0.4, 2.3, 2.4, 2.7, 1.3]
})
fig = go.Figure(go.Line(x = df['x'], y = df['y'],
name='Position (x/y)'))
fig.show()