Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set X axis range on plotly graphs?

Tags:

r

plotly

I am using R version of plotly. Here is what I want:

x = 1:100
y = 1:100
plot_ly(x, y)

I want the graph only show where x>20 and x<40, ignoring the other part. How to do this ?

like image 316
H.Ji Avatar asked Mar 11 '18 02:03

H.Ji


People also ask

How do you set the X axis range in Plotly?

Setting the Range of Axes Manually The visible x and y axis range can be configured manually by setting the range axis property to a list of two values, the lower and upper boundary. Here's an example of manually specifying the x and y axis range for a faceted scatter plot created with Plotly Express.

How do you limit y axis in Plotly?

If I understand you right you want to limit the range of the y-axis itself. You can pass a dict in the keyword argument yaxis . It could be something like go. Layout(yaxis=dict(range=[0, 10])) I hope this helps you.

How do you flip the axis in Plotly?

You can rotate the plot by setting x=-x , and/or y=-y .

How do you rotate labels in Plotly?

Tickangle=90 means that the labels will be rotated by 90° clockwise. If you use the negative sign, you rotate the labels by 90° anti-clockwise, so just the other direction.


1 Answers

Set the layout of xaxis.

y = 1:100
plot_ly(x=~x, y=~y) %>%
  layout(
    xaxis = list(
      range=c(20,40)
    )
  )

enter image description here

like image 55
hpesoj626 Avatar answered Oct 23 '22 10:10

hpesoj626