Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Modify axes range using plotly

Tags:

python

plotly

I'm using the following code to generate a bubble plot using plotly:

Dataframe.iplot(kind='bubble', x='branch', y='retention', size='active_users', text='active_users',
             xTitle='', yTitle='Retention',
             filename='cufflinks/PlotName')

I'd like to set a manual range for Y axis. Any help would be appreciated.

like image 709
Patthebug Avatar asked Apr 27 '16 18:04

Patthebug


People also ask

How do I change the Y-axis scale in Python?

To change the range of X and Y axes, we can use xlim() and ylim() methods.

How do you change Figsize in Plotly?

One of the best ways to modify the size of the Plotly figure is by adjusting the width and the height parameters. We will start by discussing how to change the height and width parameters using Plotly Express. For example, in the following code, we create a simple line chart using the default Plotly's dimensions.

How do you plot two Y-axis in Plotly?

Note: At this time, Plotly Express does not support multiple Y axes on a single figure. To make such a figure, use the make_subplots() function in conjunction with graph objects as documented below.

How do I change the axis scale in R?

To change the axis scales on a plot in base R Language, we can use the xlim() and ylim() functions. The xlim() and ylim() functions are convenience functions that set the limit of the x-axis and y-axis respectively.


2 Answers

A solution that works with subplots is:

fig.update_yaxes(range=[0, 0.4], row=1, col=1)
like image 101
aerijman Avatar answered Oct 03 '22 01:10

aerijman


import plotly.graph_objs as go    
layout = go.Layout(
        yaxis=dict(
            range=[0, 0.4]
        )
    )

    Dataframe.iplot(kind='bubble', x='branch', y='retention', size='active_users', text='active_users',
                 xTitle='', yTitle='Retention',
                 filename='cufflinks/PlotName', layout = layout)

This will do the trick.

like image 38
Patthebug Avatar answered Oct 03 '22 02:10

Patthebug