3

I am working with data visualization using matlibplot. My plot has a total of 6502 data values and is working fine, but the values are close and dense.

For example my y axis values ranges between 3 and 10 and I need to get each point between them so clearly. i.e values like 9.2 and 9.8 are to be clearly distinguished with at least a scale of 1=0.5. i.e all values like 3,3.5,4,4.5...10,10.5 are all seen in the output figure

Can some one explain me how it can be done. I tired setting range using max and min values. but it didn't work. I set the limits from 3.5 to 10.5 but in the figure the axes are displayed with scaling of 1=1 and values are from 4 to 10. Please help me fix this issue

Thanks in advance

here's my code so far

 import matplotlib.pyplot as plt
 import numpy as np
 import plotly.plotly as py

 c, ec = np.random.rand(2, len(votes), 10)
 fig, ax = plt.subplots()
 plt.ylim(3.5, 10.5)
 plt.grid(True)
 # where votes range from 10-1000000 and rank range from 3.5 to 10
 matplotlib.pyplot.scatter(votes,rank, c=c, edgecolor=ec)
 plot_url = py.plot_mpl(fig, filename='scatter-plot')
 matplotlib.pyplot.show()

and my plot is here

scatter-plot

2
  • It isn't clear what you want or what is wrong with the solution you posted. Commented Dec 13, 2014 at 6:33
  • my code is running fine. see that in my plot y axis range is from 4 to 10. i want it to be from 3.5 to 10.5 such that i can see 3.5,4,4.5,5...10.5 are all seen Commented Dec 13, 2014 at 6:41

1 Answer 1

8

use plt.yticks(np.arange(min, max, step)) instead of plt.ylim()

Sign up to request clarification or add additional context in comments.

1 Comment

just use nummbers, `plt.yticks(np.arange(3.5,10.5, 0.5))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.