Time axis not plotting

I am a newbie with plotly and python
I am using the same pandas dataframe to plot in plotly , the box plot is plotting perfectly while the line plot is throwing an error, saying that it cannot find any data.
is there something i need to check while working with line plots?

Hi @nchatter welcome to the community.

Could you please add some more information? There shouldn’t be any problem using line plots.

Thank you for your reply and sorry for the delay, i was moving :slight_smile:
So i have this dataset

Code for line plotting

import plotly.express as px
fig = px.line(combined, x=“imaging_date”, y=“field_uniformity”, color = “channel_excitation_wavelength”, title =“LSM_880_field_uniformity_over_time”)
fig.show()

Error message

If I do not plot by wavelength
fig = px.line(combined, x=“imaging_date”, y=“field_uniformity”, title =“LSM_880_field_uniformity_over_time”)
fig.show()

Result plot has totally strange plotting behaviour with time axes and the values and not plotted in order

If I use the box plot
fig = px.box(combined, x=“imaging_date”, y=“field_uniformity”, title =“LSM_880_field_uniformity_over_time”)
fig.show()

Thanks so much for your help

HI @nchatter,

could you share your data (or equivalent data) in a way that I can copy/paste it and try some stuff on my computer? Might be a problem of dtypes of your DataFrame. Did you check that?

Just a few thoughts without having more info that was requested.

If you want it to be a time series, and the data plotting in an unexpected way (your first chart). To me, that looks like your DF is not sorted by date. Perhaps in your query, add an ORDER BY [your date field] ASC.

There’s a chance the NaN’s could be causing issue in your DF. Maybe try replacing with zero and see if the output renders in a more expected way: df.fillna(0)

Hi allsyntax,

Thanks for the tip, i get a better output such as below , however although if i hover I can see the values , all the lines are not plotted

Maybe you can post your code and data or equivalent as @AIMPED noted earlier in the thread.

1 Like

Hi AIMPED, sorry for the late reply ,
This is the data after filling NA and date sorting.

imaging_date	upload_file	channel_excitation_wavelength	maximum_distortion_rate_along_Y	maximum_distortion_rate_along_X	maximum_of_the_vector_magnitudes	field_uniformity	centering_accuracy	pearson_correlation_coef_of_the_intensity_resp	pattern_dynamic_range	channel_excitation_wavelength_Ch1	channel_excitation_wavelength_Ch2	pearson_correlation_coefficient	SNR	lateral_resolution
2021-08-18	Z:/Common/4_LM/Maintenance_Service/ArgoLight/Argolight_Images_Maria/LSM880/2021-08-18_63x/GradSpecedLines_405_new.czi	405	0	0	0	0	0	0	0	0	0	0	19.60220362	0.313543399
2021-08-18	Z:/Common/4_LM/Maintenance_Service/ArgoLight/Argolight_Images_Maria/LSM880/2021-08-18_63x/2x16IntGrad_561_old.czi	561	0	0	0	0	0	0.976646908	9.848566327	0	0	0	0	0
2021-08-18	Z:/Common/4_LM/Maintenance_Service/ArgoLight/Argolight_Images_Maria/LSM880/2021-08-18_63x/2x16IntGrad_488_old.czi	488	0	0	0	0	0	0.990072748	4.572328485	0	0	0	0	0
2021-08-18	Z:/Common/4_LM/Maintenance_Service/ArgoLight/Argolight_Images_Maria/LSM880/2021-08-18_63x/2x16IntGrad_405_old.czi	405	0	0	0	0	0	0.992015606	3.312297163	0	0	0	0	0
2021-08-18	Z:/Common/4_LM/Maintenance_Service/ArgoLight/Argolight_Images_Maria/LSM880/2021-08-18_63x/2x16IntGrad_633_old.czi	633	0	0	0	0	0	0.970450157	7.311796875	0	0	0	0	0
2021-08-18	Z:\Common\4_LM\Maintenance_Service\ArgoLight\Argolight_Images_Maria\LSM880\2021-08-18_63x\2DfieldRings_4Ch_old.czi	0	0	0	2.329265281	0	0	0	0	488	561	0.805045568	0	0
2021-08-18	Z:\Common\4_LM\Maintenance_Service\ArgoLight\Argolight_Images_Maria\LSM880\2021-08-18_63x\2DfieldRings_4Ch_old.czi	0	0	0	2.833237277	0	0	0	0	488	405	0.741710956	0	0
2021-08-18	Z:/Common/4_LM/Maintenance_Service/ArgoLight/Argolight_Images_Maria/LSM880/2021-08-18_63x/2DfieldRings_633_old.czi	633	0	0	0	54.32070764	41.88054414	0	0	0	0	0	0	0
2021-08-18	Z:/Common/4_LM/Maintenance_Service/ArgoLight/Argolight_Images_Maria/LSM880/2021-08-18_63x/2DfieldRings_633_new.czi	633	0	0	0	69.17390764	91.53686379	0	0	0	0	0	0	0
2021-08-18	Z:\Common\4_LM\Maintenance_Service\ArgoLight\Argolight_Images_Maria\LSM880\2021-08-18_63x\2DfieldRings_4Ch_old.czi	0	0	0	8.08626139	0	0	0	0	488	633	0.543550841	0	0
2021-08-18	Z:/Common/4_LM/Maintenance_Service/ArgoLight/Argolight_Images_Maria/LSM880/2021-08-18_63x/2DfieldRings_561_new.czi	561	0	0	0	77.90629941	78.30753367	0	0	0	0	0	0	0
2021-08-18	Z:/Common/4_LM/Maintenance_Service/ArgoLight/Argolight_Images_Maria/LSM880/2021-08-18_63x/2DfieldRings_561_old.czi	561	0	0	0	38.90721062	83.12353815	0	0	0	0	0	0	0
2021-08-18	Z:/Common/4_LM/Maintenance_Service/ArgoLight/Argolight_Images_Maria/LSM880/2021-08-18_63x/2DfieldRings_405_new.czi	405	0	0	0	60.7327898	72.88855245	0	0	0	0	0	0	0
2021-08-18	Z:/Common/4_LM/Maintenance_Service/ArgoLight/Argolight_Images_Maria/LSM880/2021-08-18_63x/GradSpecedLines_405_old.czi	405	0	0	0	0	0	0	0	0	0	0	14.15805825	0.284172125
2021-08-18	Z:/Common/4_LM/Maintenance_Service/ArgoLight/Argolight_Images_Maria/LSM880/2021-08-18_63x/2DfieldRings_488_new.czi	488	0	0	0	66.57786776	88.18209906	0	0	0	0	0	0	0
2021-08-18	Z:/Common/4_LM/Maintenance_Service/ArgoLight/Argolight_Images_Maria/LSM880/2021-08-18_63x/2DfieldRings_488_old.czi	488	0	0	0	70.00301296	97.48671551	0	0	0	0	0	0	0
2021-08-18	Z:/Common/4_LM/Maintenance_Service/ArgoLight/Argolight_Images_Maria/LSM880/2021-08-18_63x/2DfieldRings_405_old.czi	405	0	0	0	50.43378842	68.18481232	0	0	0	0	0	0	0
2021-09-14	Z:/Common/4_LM/Maintenance_Service/Argolight measurement/Argolight_Images_Maria/LSM880/2021-09-14_63x/GradSpacedLines_405_1.czi	405	0	0	0	0	0	0	0	0	0	0	10.33570251	0.349762914
2021-09-14	Z:/Common/4_LM/Maintenance_Service/Argolight measurement/Argolight_Images_Maria/LSM880/2021-09-14_63x/GradSpacedLines_405_2.czi	405	0	0	0	0	0	0	0	0	0	0	10.96068093	0.347086782
2021-09-14	Z:/Common/4_LM/Maintenance_Service/Argolight measurement/Argolight_Images_Maria/LSM880/2021-09-14_63x/GradSpacedLines_405_3_optimal.czi	405	0	0	0	0	0	0	0	0	0	0	11.50973131	0.33266251
2021-09-14	Z:/Common/4_LM/Maintenance_Service/Argolight measurement/Argolight_Images_Maria/LSM880/2021-09-14_63x/4x4intGrad_633.czi	633	0	0	0	0	0	0.982546637	5.717938263	0	0	0	0	0
2021-09-14	Z:/Common/4_LM/Maintenance_Service/Argolight measurement/Argolight_Images_Maria/LSM880/2021-09-14_63x/4x4intGrad_488.czi	488	0	0	0	0	0	0.993546808	7.960799284	0	0	0	0	0
2021-09-14	Z:/Common/4_LM/Maintenance_Service/Argolight measurement/Argolight_Images_Maria/LSM880/2021-09-14_63x/4x4intGrad_405.czi	405	0	0	0	0	0	0.988951764	3.289317999	0	0	0	0	0
2021-09-14	Z:/Common/4_LM/Maintenance_Service/Argolight measurement/Argolight_Images_Maria/LSM880/2021-09-14_63x/2x16intGrad_633.czi	633	0	0	0	0	0	0.967574505	5.42796718	0	0	0	0	0
2021-09-14	Z:/Common/4_LM/Maintenance_Service/Argolight measurement/Argolight_Images_Maria/LSM880/2021-09-14_63x/2x16intGrad_561.czi	561	0	0	0	0	0	0.974002721	10.23769013	0	0	0	0	0