Issue
I am drawing a matplotlib
graph in ipython
but my y-ticks
are getting cut off.
I tired to use plt.tight_layout()
and plt.autoscale()
but both do not seems to work. How do I get the ticks to be shown fully?
The code that I have is: set1
and set2
are lists of same size
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import mpld3
fig, ax = plt.subplots()
fig.canvas.draw()
x = np.arange(1,len(set1)+1,1)
ax.scatter(x, set1, c='blue', s=200, alpha=0.5)
ax.scatter(x, set2, c='red', s=200, alpha=0.5)
ax.grid(color='lightgray', alpha=0.7)
plt.xlim(0,500)
plt.tight_layout()
#plt.autoscale()
mpld3.display(fig)
Solution
you could adjust where the edges of the axes object is with subplots_adjust
For example
fig, ax = plt.subplots()
fig.subplots_adjust(left=0.2) #Adjust 0.2 to find the right margin for your plot
I think that tight_layout
will override this setting, so you may need to turn that off.
Answered By - tmdavison
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.