how can I change the position of the y-axis labels to the right side? The standard is of course on the left side, but I want to have it on the right side.
I can’t find anything in the holoviz panel documentation to it.
I tried to derive it from the position settings of the legend. So, I thought p.y_axis_label_text_align = 'right’ could be right. However, it does not work.
Can anybody help me out or has a Python panel example where the y-axis is located on the right side of the chart tile? Thanks in advance.
The answer depends on the package you are using.
Holoviews
If your figure is created with holoviews, please cheack out the holoviews documentation for axis-positions.
In gerneal
.opts(xaxis='top', yaxis='right')
does the trick.
bokeh
If you are using the the figure of bokeh.plotting, then
p = figure(..., y_axis_location="right", ...)
moves the one y-axis to the right.
In case you want to add a new axis, the twin-axis example shows how to add a LinearAxis.
Related
I have an assignment that is requiring us to create a dot grid along with a curser that moves up, down, right, left, on the grid when given the command. I can't get my move functions to work along with the grid showing with the updated coordinate. This is what I have so far.
It looks like it might be an import issue or you need to define method for show_grid(x,y). Let me know if this helps!
I am trying to display spectrograms in a Flask application. I use matplotlib for creating the spectrograms and mpld3 for displaying them in an HTML file with the default toolbar.
The problem is that I am not able to zoom into the same region for each spectrogram at the same time.
This is a screenshot of default figure
This is another screenshot that I took after zooming in a little bit on a left top one.
As you can see, all of the y-axes have been changed with the same scale as the left top ones. However, the x-axes of the right top, the left bottom, and the right bottom haven't been changed at all. So what I want to do is to compare those guys with the same scale.
Does anyone have any suggestion such as a better idea to make it possible or maybe the solution for the problem?
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
I'm now embedding matplotlib plot in a simple GUI. During the customization of the plot, I found some displaying issues occurred when I added tool bar under the plot using NavigationToolbar2TkAgg. Now I want to disable displaying coordinate at right side of the bottom of plot when mouse moves around the plot, if we add tool bars at the left side of the bottom. Any idea about this?
Thanks in advance.
Update:
For a figure simply drawn by plt.plot(x,y), the coordinates are displayed at left side of the bottom along with mouse moving as tool bars (like "home", "zoom" etc.) are listed at the top by default. It will be much clearer to view the screen shot at google drive here and I highlighted the coordinates in yellow, which one can find at the bottom left of the image. Thanks GWW and jgysland for reminding me.
You want the opposite of matplotlib values under cursor, but the solution is the same, you need to over-write the format_coord attribute on the Axes object.
ax.format_coord = lambda x, y: ''
should do the trick where ax is a reference to the axes object you care about.
Another option is to sub-class NavigationToolbar2TkAgg and make the set_message function a no-op
class my_toolbar(NavigationToolbar2TkAgg):
def set_message(self, msg):
pass
It's a simple thing but I've searched for quite a while without success: I want to customise a figure legend by reversing the horizontal order of the symbols and labels.
In Gnuplot, this is simply achieved by set key reverse. Example: change x data1 to data1 x. In matplotlib, there seems to be no user-friendly solution. Thus, I thought about changing a kind of handle anchor or just shifting the handle's position, but couldn't find any point to start with.
The requested feature is already there, as the keyword markerfirst of the legend command.
plt.plot([1,2],[3,4], label='labeltext')
plt.legend(markerfirst=False)
plt.show()
If you want to make it your default behaviour, you can change the value of legend.markerfirst in rcParams, see customizing matplotlib.