This question already has answers here:
How to set yaxis tick label in a fixed position so that when i scroll left or right the yaxis tick label should be visible?
(2 answers)
Closed 3 years ago.
I have a lot of data series (> 1000 bars). For this reason the plot is scaled very small. Do you know how I can activate a scrollbar in the plt.barh-chart with python? If I can set a fixed height of the bars then I can scroll through the > 1000 bars. Perhaps you have another solution for me?
You have to set position for scrollbar with respect to image size.
Kindly refer a below URL:
Scrollable Bar graph matplotlib
Could you provide a reproducible example? Other than that I can just give you plain advice. First of all, ask you whether you are really in need of Youtube/Netflix/etc. 1-10. Because it makes the chart very confusing. I came across the same problem some time ago too and I figured that the Gantt Chart from Plotly, particularly for Python, is a really good solution to make it clearer.
As for your original question:
fig= plt.figure(figsize=(6,3))
Related
This question already has answers here:
How to draw rectangle outside of the plot frame in Matplotlib
(2 answers)
How to position a matplotlib patch outside of the axes range (so that it could be next to the title, or legend, or anywhere on the figure)
(2 answers)
Closed 5 months ago.
I would like to draw a rectangle over a matplotlib figure, in a way that allows overlaying the axes.
The answers I found online only allow drawing a rectange inside the axes, but not overlaying them.
EDIT: This answer allows drawing outside the plot frame. However it does not overlay the axis. Namely, the axis is kept visible. See the example where the axis is still visible behind the red rectangle
See an example below for what I wish to achieve (Code for the bar plot can be taken from here. For the example, the figure was edited with a simple paint software).
It is drawn via matplotlib.pyplot.hist() function in matplotlib
This question already has an answer here:
Remove the x-axis ticks while keeping the grids (matplotlib) [duplicate]
(1 answer)
Closed 5 years ago.
If I run this code
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111)
ax.xaxis.set_tick_params(length=0,labelsize=0)
ax.grid(True)
I get the following:
The xaxis ticks and labels don't show (as expected), but some dashes appear on the bottom of the plot (the first three of which I have circled in red).
How can I remove them? I have looked at the documentation for grids, but can't find anything.
An answer which teaches me how I could have figured out how to do this by looking at the documentation would be particularly useful.
What you see are the ticklabels, which have size 0. Even zero sized ticks appear as a single dot because of antigraining.
You probably want to set the label off completely
ax.xaxis.set_tick_params(length=0,labelbottom=False)
You find out about this by looking at the available arguments in the documentation.
This question already has answers here:
How do I change the size of figures drawn with Matplotlib?
(14 answers)
Closed 5 years ago.
I have all of my graphs working, so now I am trying to scale my plots down to a relatively small size (3x3in). I added the figure command and the graph goes blank. Right size, just blank. I'm obviously missing something basic but it's beating me. When I comment it out, it shows fine ( if a bit big). When I include it, it blanks the image.
What am I doing incorrectly ?
plt.setp(line[lindex], linewidth=1.0)
plt.setp(line[lindex+1], linewidth=2.0)
plt.xlabel("Months")
plt.ylabel("Score")
plt.title(CurrAppName + "- by month")
plt.legend()
# plt.figure(figsize=(3,3))
plt.show()
If this is your whole code, just put the plt.figure(figsize=(3, 3)) as the first line. Here, declaring plt.figure(...) in the end means you are creating a whole new plot after you've drawn into the last one. You don't want that.
This question already has an answer here:
In matplotlib, what's the difference between title() and suptitle()?
(1 answer)
Closed 5 years ago.
I understand that matplotlib.figure.suptitle() adds a title to a figure.
But what does the "sup" stand for?
It is an abbreviation indicating a "super" title. It is a title which appears at the top of the figure, whereas a normal title only appears above a particular axes. If you only have one axes object, then there's unlikely an appreciable difference, but the difference happens when you have multiple subplots on the same figure and you would like a title at the top of the figure not on each of the axes objects.
I am trying to configure my Bokeh plots in Python such that they look a bit nicer. For example, is there a way to fix the maximum zoom out? Such that Bokeh cannot zoom out more than what is specified by the x-axis? E.g. look at bokeh example, and especially "Datetime axes". I would like to fix the axis size so that you cannot zoom out more than the initial x axis is wide.
Another question; is there a way to fill an area under a curve in a specified color? Like in the figure USDSEK. I can provide code, but I don't think it's necessary for the problem at hand.
UPDATED for 2019:
Bokeh now supports "directed areas" (which can also be stacked) see e.g.
https://docs.bokeh.org/en/latest/docs/gallery/stacked_area.html