I am using plotly to show some graph. I add a slider as shown in the picture. I would like to add the x values in the axis of the slider as shown in the pic:
fig.update_layout(xaxis=dict(autorange=True,
range[df.index.to_list()[0], df.index.to_list()[-1]], rangeslider=dict(autorange=True,
range=[df.index.to_list()[0], df.index.to_list()[-1]],
bordercolor="red",
borderwidth=3,
visible=True,
#### HERE code to show the axis ####),
type="date"),
https://plotly.com/python/reference/layout/xaxis/#layout-xaxis-rangeselector
I dont see any possibility in the API to show the x axis of the slider, but it should be possible. Any idea?
I think this is impossible to do with plotly. As you see in the API docs you just sent the link of, there is no attribute like “showxaxis” or the like.
Related
I'm creating a bar chart using Bokeh. My chart renders fine initially, but when I add in the following line (to rotate the X labels):
p.xaxis.major_label_orientation = 1.2
The chart becomes blank. Why is this occurring?
It turns out that this occurred because my x axis labels were too long. When I shortened the labels, the chart reappeared with the rotated labels. (Increasing the height of the figure might be another way to solve this issue.)
I currently annotate my charts with the last value of each series by adding a Label and supplying my the name of corresponding range it's plotted on:
Label(
...
x=data.index.max(),
y=data.loc[data.index.max(), 'my_col'],
y_range_name='my_range'
...
)
Which gives me:
How do I move the labels so they are positioned on their respective axis?
Example:
Please note that my labels' y-positioning is off, so I need some help with that aspect too. I've tried tweaking the y_offset but this has not yielded any consistently good results.
My data are always numerical time series.
As of Bokeh 1.2 there is no built-in annotation or glyph that will display outside the central plot area. There is an open issue on GitHub that this is similar to that you can follow or comment on. For the time being, something like this would require making a custom extension
In Bokeh 0.12.2, I was able to make a stacked bar chart with various hover tooltips using plotting and VBars. I also enabled a legend for the plot. However, my vbars are colored and the colors for each vbar (each stack) are not appearing in the legend. Only the names for the stack in the legend are appearing. Is this not an implemented feature yet or a bug maybe? Or maybe I'm missing something?
what my chart looks like
This was due to a bug in the bokeh source code which is being fixed if not fixed already.
I'm trying to retrieve the range of the x-axis when you zoom in a plotly scatter plot, but when I tried to access it using:
figure['layout']['xaxis']['range']
it just returns 'None'.
This is the code that I am using to create the graph:
# self.plot contains the dataframe passed to the function to be plotted
self.plot = df
# Creates the plotly plot figure
self.fig = self.plot.iplot(asFigure=True,kind='scatter', xTitle='Date', yTitle='Temperature')
# Displays the plot
iplot(self.fig, show_link=False)
I'm using cufflinks to create the plot from a pandas DataFrame so I don't explicitly set the layout.xaxis.range to anything. Also I'm using a Jupyter Notebook to display the graph, if that helps at all. So is there any way of getting the range of the x-axis of the current view window of the plot? Thanks in advance!
That does not seem to be possible at the moment using python. There's a post on community.plot.ly that says:
Graph parameters don’t dynamically change with chart actions. However,
as you zoom, the plot does emit data regarding the new x-axis range,
you’re unable to to access this information directly in Python.
Instead you’d have to use javascript:
https://plot.ly/javascript/zoom-events/
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