Reputation: 587
I have made a error-bar plot using matplotlib but it is too crowded to see everything without zooming in. I can of course do this but when I save the plot I can only save the zoomed in bit and lose the rest of the data.
Is there a way to get a scrollable plot with matplotlib so that when I save it as a png everything is included or any other format such that no data is lost? Essentially I would like the length of the plot to be much greater than the width.
The code I used to plot is:
plot1_dataerr = get_plot_data_errbars(processed_answers[0][plot_low:]) #the data to be plotted, the zeroth element of this is the labels, the first is the means and the second is the errorbar size
fig, axs = plt.subplots()
fig.subplots_adjust(left=0.2)
axs.set_xlim([1,5])
axs.grid()
axs.errorbar(plot1_dataerr[1],range(len(plot1_dataerr[1])),xerr = plot1_dataerr[2], fmt = 'k o')
axs.yaxis.set_ticks(np.arange(len(plot1_dataerr[1])))
axs.set_yticklabels(plot1_dataerr[0])
And here is the plot I am getting, as you can see it is very crowded and unclear:
Upvotes: 0
Views: 3780
Reputation: 339112
You may increase the size of the plot
plt.subplots(figsize=(18,10))
This of course has a limitation for showing the plot on the screen. So you may as well or additionally, decrease the dots per inch,
plt.subplots(figsize=(36,20), dpi=50)
Then saving the plot in a vector format like pdf will allow you not to loose any details in the saved figure.
You may also keep the dpi, increase the figuresize and finally show your plot in a window with scrollbars. This is shown e.g. in the question Scrollbar on Matplotlib showing page
Upvotes: 3
Reputation: 585
You can specify a bigger figure size in the subplots()
constructor.
fig, axs = plt.subplots(figsize=(w, h))
Where w
and h
are the width and height in inches.
Upvotes: 0