plotly-python

How to add time frame for candle using plotly library in Python?

How to add time frame for candle using plotly library in Python? Question: I want to add a time frame for candlestick on a chart using plotly library. Is there a way to do that without iterating through data and taking every 4th tick (for 4h chart) and calculating high and low in between and …

Total answers: 1

Plotly imshow reversing y labels reverses the image

Plotly imshow reversing y labels reverses the image Question: I’d like to visualize a 20×20 matrix, where top left point is (-10, 9) and lower right point is (9, -10). So the x is increasing from left to right and y is decreasing from top to bottom. So my idea was to pass x labels …

Total answers: 3

Adding multiple lines to a strip plot in plotly

Adding multiple lines to a strip plot in plotly Question: I would like to add multiple short lines to a strip plot in plotly, preferably in a way that scales to adding more columns/categories. In my actual problem I have quite a few more columns. It would also be awesome if these lines could have …

Total answers: 1

How do I make the space between subplots smaller?

How do I make the space between subplots smaller? Question: I have this subplot- fig = make_subplots(rows = 4, cols = 1) fig.append_trace(go.Scatter( x=[3, 4, 5], y=[1000, 1100, 1200], ), row=1, col=1) fig.append_trace(go.Scatter( x=[2, 3, 4], y=[100, 110, 120], ), row=2, col=1) fig.append_trace(go.Scatter( x=[0, 1, 2], y=[10, 11, 12] ), row=3, col=1) fig[‘layout’].update(margin=dict(l=0,r=0,b=0,t=0)) I also …

Total answers: 1

Joining traces in plotly

Joining traces in plotly Question: I am trying to make a shape conformed by a few traces, many of which are not continuous. By the moment, I’ve managed to create this shape with different traces. I’ve tried calling them the same name, but this didn’t work. For instance: import plotly.graph_objects as go fig = go.Figure(go.Scatter(x=[1,2,0], …

Total answers: 1

How can I convert Plotly graph to a PNG image

How can I convert Plotly graph to a PNG image Question: I have this Plotly graph, and I’m trying to save it as a png or JPEG file import plotly.graph_objects as go import numpy as np np.random.seed(1) N = 100 x = np.random.rand(N) y = np.random.rand(N) colors = np.random.rand(N) sz = np.random.rand(N) * 30 fig …

Total answers: 1

How to add an animated horizontal line in a python animated scatter plotly graph?

How to add an animated horizontal line in a python animated scatter plotly graph? Question: Let’s take a sample example of animated scatter graph from plotly site : import plotly.express as px df = px.data.gapminder() fig = px.scatter(df, x="gdpPercap", y="lifeExp", animation_frame="year", animation_group="country", size="pop", color="continent", hover_name="country", log_x=True, size_max=55, range_x=[100,100000], range_y=[25,90]) fig.show() I would like to add …

Total answers: 1

Plotly ticks are weirdly aligned

Plotly ticks are weirdly aligned Question: Let’s take the following pd.DataFrame as an example df = pd.DataFrame({ ‘month’: [‘2022-01’, ‘2022-02’, ‘2022-03’], ‘col1’: [1_000, 1_500, 2_000], ‘col2’: [100, 150, 200], }).melt(id_vars=[‘month’], var_name=’col_name’) which creates month col_name value —————————– 0 2022-01 col1 1000 1 2022-02 col1 1500 2 2022-03 col1 2000 3 2022-01 col2 100 4 2022-02 …

Total answers: 1

How to adjust Plotly legend/colorbar background transparency/colour

How to adjust Plotly legend/colorbar background transparency/colour Question: I’m trying to edit the appearance of a map I have made, but if I choose to have the colorbar/legend visible, it sits on a white background: This white is a bit jarring for the rest of the color scheme. At the moment, I’m just hiding the …

Total answers: 1