question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

accept int for rows and cols in `fig.add_traces`

See original GitHub issue

At the moment if you want to add several traces to the same subplot you have to pass an iterable to the rows and cols arguments of fig.add_traces.

import plotly.express as px
df = px.data.tips()
fig = px.scatter(df, x='total_bill', y='tip', color='day')
from plotly.subplots import make_subplots
fig2 = make_subplots(1, 2)
fig2.add_traces(fig.data, rows=[1,]*len(fig.data), cols=[1,]*len(fig.data))
fig2.show()

We could also accept an int here, in which case all traces would be added to the same subplot.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
nicolaskruchtencommented, Jun 4, 2020

@MCBoarder289 if you’re interested, solving this issue might involve the same area of the code you were just in 😃

0reactions
nicolaskruchtencommented, Jun 4, 2020

Awesome! Please don’t feel any pressure to work on it or anything, I was just flagging it in case you were looking for a (possibly easy) entry-point into another PR here 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

plotly.subplots.make_subplots — 5.11.0 documentation
Figure with predefined subplots configured in 'layout'. Parameters. rows (int (default 1)) – Number of rows in the subplot grid. Must be greater...
Read more >
how to plot multiple charts using make_subplot in plotly and ...
1 Answer 1 · 1 · In the example shown in the comments, the graph has nine columns and two rows. · so...
Read more >
plotly package — 5.11.0 documentation - Plotly Help Center
row (int or None (default None)) – Subplot row and column index of traces to select. To select traces by row and column,...
Read more >
Creating Various Plot Types and Subplots with Plotly
All we have to do now is when we add a trace to our figure, we need to provide a row and column...
Read more >
How to apply different titles for each different subplots using ...
Syntax: make_subplots(rows=int, cols=int, subplot_titles= 'title'). Parameters: ... In this example, we have selected 1 row with 2 columns, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found