Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove space between subplots in Plotly?

Tags:

plotly

I have a a large space in between my subplots in plotly. In matplotlib, there is a layout called a tight layout that removes this. Is there any similar layout in plotly? I am plotting in an iPython notebook so there is limited space. See the space in the image below.

enter image description here

like image 879
pr338 Avatar asked Jul 20 '15 20:07

pr338


People also ask

How do you reduce the space between subplots Plotly?

The vertical_spacing argument is used to control the vertical spacing between rows in the subplot grid. Here is an example that creates a figure with 3 vertically stacked subplots with linked x axes. A small vertical spacing value is used to reduce the spacing between subplot rows.

What is Add_trace in Plotly?

Adding Traces To Subplots If a figure was created using plotly. subplots. make_subplots() , then supplying the row and col arguments to add_trace() can be used to add a trace to a particular subplot.

What is domain in Plotly?

In short, domain just specifies which space of the total plot area is occupied by the subplot.

How many points can Plotly handle?

Due to browser limitations, the Plotly SVG drawing functions have a hard time graphing more than 500k data points for line charts, or 40k points for other types of charts.


1 Answers

Yes there is! You can use specs and vertical_spacing or horizontal_spacing. Here is an example for horizontal_spacing:

from plotly import tools
import plotly.plotly as py
from plotly.graph_objs import *

trace1 = Scatter(
     x=[1, 2, 3],
     y=[4, 5, 6]
)
trace2 = Scatter(
     x=[20, 30, 40],
     y=[50, 60, 70],
)

fig = tools.make_subplots(rows = 1, cols = 2, specs = [[{}, {}]],
                          horizontal_spacing = 0.05)

fig.append_trace(trace1, 1, 1)
fig.append_trace(trace2, 1, 2)

py.iplot(fig, filename='make-subplot-horizontal_spacing')

here is the plot

You can find more tutorials on Plotly subplots page: Plotly subplots tutorial

like image 53
neda Avatar answered Oct 05 '22 14:10

neda