Mar-23-2024, 10:55 PM
I have a dataset that I'm importing from a CSV into a dataframe in python. I need to make a simple line graph out of it.
Here is my code:
plt.gca().xaxis.set_major_formatter(ticker.ScalarFormatter(useMathText=False))
plt.ticklabel_format(useOffset=False)
plt.gca().xaxis.set_major_formatter(ticker.ScalarFormatter(useOffset=False))
And still it's showing as scientific notation. Any advice on how to force it to use the full number?
Here is my code:
# Create the line graph
plt.plot(x_values, y_values, marker='o', linestyle='-')
# Customize the x-axis tick formatter
#plt.gca().xaxis.set_major_formatter(ticker.ScalarFormatter(useMathText=False))
plt.ticklabel_format(useOffset=False)
#plt.gca().xaxis.set_major_formatter(ticker.ScalarFormatter(useOffset=False))
# Add labels and title
plt.xlabel('X')
plt.ylabel('Y')
plt.title('Data')
# Display the graph
plt.grid(True) # Add grid lines
plt.show()So my Y axis data ranges in value from 190-197 and has a precision of two decimal places. Simple enough. My X axis data however is time measured in nanoseconds - and my data set spans an hour of time starting at 34200001686628 and ending at 37798014509685 - I have about 27300 data points in my data set. I am graphic this because I want to be able to zoom in and look at the microscale data when graphed. The problem is no matter what I seem to try, matplotlib uses scientific notation on the X axis. In order to make sense of my data, I need to see the full timestamps - with no scientific notation. I have tried:plt.gca().xaxis.set_major_formatter(ticker.ScalarFormatter(useMathText=False))
plt.ticklabel_format(useOffset=False)
plt.gca().xaxis.set_major_formatter(ticker.ScalarFormatter(useOffset=False))
And still it's showing as scientific notation. Any advice on how to force it to use the full number?
