Skip to content

Fix for issue#1002. #1005

Closed
rysktky wants to merge 2 commits into
plotly:masterfrom
rysktky:issue1002_develop
Closed

Fix for issue#1002. #1005
rysktky wants to merge 2 commits into
plotly:masterfrom
rysktky:issue1002_develop

Conversation

@rysktky

@rysktky rysktky commented May 9, 2018

Copy link
Copy Markdown

subplot_titles position issue when shared_yaxes and/or shared_xaxes is True and start_cell is bottom-left.

Tested with this code.

from plotly import tools
import plotly.offline as py
import plotly.graph_objs as go

trace1 = go.Scatter( x=[1, 2], y=[10,10,10])
trace2 = go.Scatter( x=[1, 2], y=[20,20,20])
trace3 = go.Scatter( x=[1, 2, 3], y=[30,30,30])
trace4 = go.Scatter( x=[1, 2, 3], y=[40,40,40])
trace5 = go.Scatter( x=[1, 2, 3], y=[50,50,50])
trace6 = go.Scatter( x=[1, 2, 3], y=[60,60,60])
trace7 = go.Scatter( x=[1, 2, 3], y=[70,70,70])

fig = tools.make_subplots(rows=7, cols=1, 
                          shared_xaxes=True,
                          start_cell='bottom-left',
                          vertical_spacing=0.03,
                          subplot_titles=('trace1','trace2','trace3','trace4','trace5','trace6','trace7'))

fig.append_trace(trace1, 1, 1)
fig.append_trace(trace2, 2, 1)
fig.append_trace(trace3, 3, 1)
fig.append_trace(trace4, 4, 1)
fig.append_trace(trace5, 5, 1)
fig.append_trace(trace6, 6, 1)
fig.append_trace(trace7, 7, 1)

fig['layout'].update(showlegend=False, title='Test for issue 1002')
py.plot(fig, filename='Test4Issue1002.html')

Result with current code.
before

Result with the fix. subplot_titles are positioned and ordered correctly.
after

@jonmmease

Copy link
Copy Markdown
Contributor

Hi @rysktky , thanks for the PR. If you're still interested, could you do the following:

  1. Merge in master and then push again so that our new test suite runs.
  2. Add a test or two to plotly/tests/test_core/test_tools/test_make_subplots.py.

Thanks!

@jonmmease

Copy link
Copy Markdown
Contributor

This issue will be fixed in version 4 by #1528.

You can try it out with version 3.8+ using the v4_subplot future flag.

from _plotly_future_ import v4_subplots
from plotly import tools
import plotly.offline as py
import plotly.graph_objs as go

trace1 = go.Scatter( x=[1, 2], y=[10,10,10])
trace2 = go.Scatter( x=[1, 2], y=[20,20,20])
trace3 = go.Scatter( x=[1, 2, 3], y=[30,30,30])
trace4 = go.Scatter( x=[1, 2, 3], y=[40,40,40])
trace5 = go.Scatter( x=[1, 2, 3], y=[50,50,50])
trace6 = go.Scatter( x=[1, 2, 3], y=[60,60,60])
trace7 = go.Scatter( x=[1, 2, 3], y=[70,70,70])

fig = tools.make_subplots(rows=7, cols=1, 
                          shared_xaxes=True,
                          start_cell='bottom-left',
                          vertical_spacing=0.03,
                          subplot_titles=('trace1','trace2','trace3','trace4','trace5','trace6','trace7'))

fig.append_trace(trace1, 1, 1)
fig.append_trace(trace2, 2, 1)
fig.append_trace(trace3, 3, 1)
fig.append_trace(trace4, 4, 1)
fig.append_trace(trace5, 5, 1)
fig.append_trace(trace6, 6, 1)
fig.append_trace(trace7, 7, 1)

fig['layout'].update(showlegend=False, title='Test for issue 1002')
py.plot(fig, filename='Test4Issue1002.html')

newplot-6

Thanks for getting this started @rysktky!

@jonmmease jonmmease closed this May 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants