1

Is there a way to change the interval for the x-value? they're pretty clumped up right now and i dont need to show everyone, i may only need to show 1 per 20.

Pic of the graph

def create_window_graph(xas,yas,labname):

fig = Figure(figsize=(8, 4), dpi=80)

fig.add_subplot(111).plot(xas,yas, 'r--', label = labname) 


fig.legend()
steffen
  • 67
  • 8

1 Answers1

0

Using maptplotlib.pyplot it's pretty straightforward:

ax.set_xlim(xmin = , xmax = )

You can see the full documentation here:

https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.axes.Axes.set_xlim.html

DPM
  • 845
  • 7
  • 33
  • Ah yes it did work, but not quite what i thought about, since i want it to plot all the values like above in the image, but i dont want it to show the text for each value it plots on the x graph if that make sense ? Like if i have a graph that plots from 0-20 and i only want the text to show 5 10 15 20. And not every number from 1-20 in the text – steffen May 04 '20 at 22:55
  • If I understand you want to plot everything, but only show specific ticks? – DPM May 04 '20 at 23:14
  • I have the solution for your problem. Matplotlib has a built in function that does the trick: you can select a list values that will be the ticks in the x axis: matplotlib.pyplot.xticks( ) Full documentation: https://matplotlib.org/3.1.0/api/_as_gen/matplotlib.pyplot.xticks.html – DPM May 05 '20 at 12:45
  • You also have here a solution for a question that is the same as yours: https://stackoverflow.com/questions/12608788/changing-the-tick-frequency-on-x-or-y-axis-in-matplotlib – DPM May 05 '20 at 12:48