1

I have a code that draws the voltage of a battery in discharge mode vs time in real-time with drawnow but after a while, the time label ticks get too close to each other that no one can read it how to set an automatic scale factor like plt.autoscale for x-axis so the time get separated and update every time thnks

def CreatePlot():

  plt.subplot(2,2,1)
  plt.grid(True)
  plt.ylabel('Voltage')
  plt.plot(Time,Voltage_0,'g-', label='V1')
  plt.autoscale()

Time

and

Voltage_0

are lists that are appending through time

Sample image of X axis overlaps:
enter image description here

Mr. T
  • 11,960
  • 10
  • 32
  • 54
  • `plt.MaxNLocator(3)`In this case, control the z-axis scale to three. – r-beginners Feb 28 '21 at 13:57
  • @r-beginners can you be please more specific – Fander Hall Feb 28 '21 at 14:08
  • Didn't it change when you replaced it with plt.autoscalse()? – r-beginners Feb 28 '21 at 14:26
  • @r-beginners yes it almost doubled the amount of readable labels but it still is far from what I want, without plt.MaxNlocator(3) I could see 5 mins of labels in 90 rotation, with plt.MaxNlocator(3) I can see around 10 mins but the program shall to be work for more than 90 mins, is there anyway to combine labels and recalculate to arrange them, or just show some of them not all but have all range? – Fander Hall Feb 28 '21 at 14:44
  • Kindly refer to [this](https://matplotlib.org/stable/gallery/text_labels_and_annotations/date_index_formatter.html#sphx-glr-gallery-text-labels-and-annotations-date-index-formatter-py). – r-beginners Feb 28 '21 at 15:00
  • @r-beginners thanks, let's see what it is – Fander Hall Feb 28 '21 at 15:44

0 Answers0