0

I´m looking to add a specific range of values to the x-axis of my plot and increase the length of this axis. I change the range of the values of my x-axis; however, the values keep in a specific range. Besides, I tried to increase the length of the x-axis but I failed again. For now, I´m only plotting an empty graph, because a need to set the specifications for the axis. Here is part of the code to the plot:

fig1, ax = plt.subplots()

ax.set_xlim(1, 1200)
ax.set_ylim(-800, 200)
ax.set_box_aspect(1)

plt.show()

This code gives me a plot square with the range of the:

x-axis = 0-200-400...1200, 

I´m looking for:

x-axis = 0-50-100-150...1200

Also, I need to change the shape of the plot: square to a rectangular, where the x-axis increases the length. Any suggestion or comment is welcome!

Thank!

Mauri1313
  • 345
  • 4
  • 12

2 Answers2

3

plt.figure(figsize=(15,2))

Use this at first line to set the size of your plot. As you want to increase x-axis, then see that x>y in figsize parameter.

l1=np.arange(0,1250,50)
plt.xticks(l1)

Use the above code after setting y limits to set the xticks in range of 0-1200 with gap of 50. ``

Pavan Kumar
  • 116
  • 3
0

You can change the size (and therefore the shape) of a pyplot figure like this:

fig1.set_size_inches(10, 8)

As for the ticks on the axis, this post gives a pretty in-depth answer on how to customize those.