I am using matplotlib to live plot some data from a current sensor and it sometimes picks odd scaling factors that make it very difficult to interpret e.g.
It often does plot it without the scaling factor e.g.
which is preferable as it is much easier to read the plot without a scaling factor.
I am using the following to scale the axes every loop step:
ax.set_xlim(min(x),max(x))
ax.set_ylim(min(y),max(y))
Is there a way to force matplotlib to avoid plotting the y-axis as it is doing in the first picture?
I don't know what the y-limits will be ahead of time and they could span a large range so I can't fix them to some constant value. Also, as I am plotting an updating plot within a tkinter GUI, the figure only autoscales on the initialisation of the plot.
Here is some minimal code to show how I am plotting within tkinter:
### initialise graph ###
self.fig, self.ax = plt.subplots(
1,1,
figsize=(6.5,4),
dpi=150,
tight_layout = True
)
self.line, = self.ax.plot([],[]) #empty graph
self.GUIFig = FigureCanvasTkAgg(self.fig, root)
x = []
y = []
while True:
x.append(time_delta)
y.append(current_sensor_reading)
self.line.set_xdata(x)
self.line.set_ydata(y)
self.ax.set_xlim(min(x),max(x))
self.ax.set_ylim(min(y),max(y))
self.GUIFig.draw()