0

I am plotting a graph in python. This is my code for that:

plt.plot(X,Y,'rx') plt.savefig('plotOr.png')

However, I am not getting a good Y-axis graph because the numbers (the unit scale) are overlapping. The picture is here.

enter image description here

What must I change to get a uniform scale of 1 on the left hand side (starting from 5 and ending at 10)? Same for the x-axis

Thanatos
  • 282
  • 5
  • 18

1 Answers1

0

Well, Python has a built-in function called "set()" and you could use it on your "Y" array so that the numbers in it won't get repeated.

That of course, won't help you if the numbers are similar yet not the same (I.e. 4.4 and 4.5).

In that case you might want to consider making your graph bigger and adding more space between each unit on the scale. The size of the plot can be changed by setting the dynamic rc settings of Matplotlib. These are stored in a dictionary named rcParams. The size of the plot figure is stored with the key figure.figsize.

As an example, to get and set the size of a Matplotlib plot:

import matplotlib.pyplot as plt

# Get current size
fig_size = plt.rcParams["figure.figsize"]

# Prints: [8.0, 6.0]
print "Current size:", fig_size

# Set figure width to 12 and height to 9
fig_size[0] = 12
fig_size[1] = 9
plt.rcParams["figure.figsize"] = fig_size
Franco Roura
  • 807
  • 8
  • 26