Hello everyone. Iβm an absolute beginner in coding, python, plotly β¦ you name it.
As a personal peak performance I managed to install anaconda, install Plotly and pandas and copy some Plotly Express examples into a Jupyter Notebook in an attemp to plot a very simple 2 dimensional graph with several reverberation times over frequency.
A graph in Excel/Calc looks like this:
Simple enough. However, I am not succesful in replicating the graph in Plotly:
import pandas as pd
import plotly.express as px
df = pd.read_csv('C:\\Users\\cer\\plotly_tests\\20221022\\RT_GN6021_VGL.csv', sep=';')
fig = px.line(df, x = 'F', y = ['A_T20_T', 'B_T20_T', 'A_T30_T', 'B_T30_T', 'A_T20_O', 'B_T20_O', 'A_T30_O', 'B_T30_O'], log_x=True)
fig.show()
gives me:
Problem: The y-axis is not in order. If I check the CSV data with df.head()
the data looks ok.
This is the content of the CSV file:
F;A_T20_T;B_T20_T;A_T30_T;B_T30_T;A_T20_O;B_T20_O;A_T30_O;B_T30_O
125;1,4;0,8;1,5;0,9;1,3;0,8;1,3;0,9
250;1,2;0,9;1,2;0,9;1,1;0,9;1,1;0,9
500;1,3;1;1,3;1;1,3;1;1,3;1
1000;1,3;0,9;1,3;0,9;1,3;0,9;1,3;0,9
2000;1,2;0,8;1,2;0,8;1,2;0,9;1,2;0,9
4000;1,1;0,8;1,1;0,8;1,1;0,8;1,1;0,8
I figured out that there is a problem with the CSV import. If I manually type in values into arrays the y-axis looks fine:
import pandas as pd
import plotly.express as px
x = [125, 250,500,1000,2000,4000]
y = [1.4, 1.2, 1.3, 1.3, 1.2, 1.1]
y1= [1.5, 1.2, 1.3, 1.3, 1.2, 1.1]
fig = px.line(x=x, y=[y,y1], log_x=True)
fig.show()
It would be important for me to use CSV (or other table) files. Can anyone explain to me whatβs happening here with the data? Is there a problem with my data layout, does plotly need something like an extra row to define the y-axis?
Also: I have the feeling that Jupyter Notebook might not be the best tool for me. It was what the first tutorial was advising me to use. I assume that Iβm looking for an IDE: Any other recommendations in this regard?
Many thanks for you time
Chris