Mixed up axes assignments in subplots
See original GitHub issueThe trace
s in the bottom 2 subplot axes are assigned to axes (x2, y3) and (x3, y2). For clarity, this is how these assignments look in the JSON editor:
If I changes the axes assignments of these traces to the correct (x2, y2), (x3, y3), one of the subplots disappears - this is the bug. There seems to to be an issue with trace-axes assignment.
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Clearing the confusion once and for all: fig, ax = plt.subplots()
On a single notebook or a script, you can have multiple figures. Each figure can have multiple subplots. Here, subplot is synonymous with...
Read more >How do I change matplotlib's subplot projection of an existing ...
but I was wondering if there is a proper matplotlib method to change a subplot axis projection after it was defined.
Read more >Understanding Usage of plt, figure, subplot, axes, axis in ...
When working with python libraries, especially for visualization, I usually get confused my number of options available for plotting. Example: 1. plt.plot() ...
Read more >Subplots with Matplotlib in Python - YouTube
Subplots combine multiple plots into a single frame. The key to using subplots is to decide the layout of the subplots and to...
Read more >Easy Chart - Subplots - Ignition User Manual 8.0
The subplot feature of the Easy Chart component allows you to break up the chart plot area into multiple distinct subplots sharing the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This bug appears fixed:
gives (I believe) the desired result:
This was probably fixed in @alexcjohnson 's https://github.com/plotly/plotly.js/pull/2227 and/or https://github.com/plotly/plotly.js/pull/1854
In[]:
Imports required libraries
from datetime import datetime import numpy as np import pandas as pd
import plotly.plotly as py from plotly.graph_objs import * from plotly.grid_objs import Grid, Column
mapbox_access_token = ‘pk.eyJ1IjoiamFja2x1byIsImEiOiJjaXhzYTB0bHcwOHNoMnFtOWZ3YWdreDB3In0.pjROwb9_CEuyKPE-x0lRUw’
In[]:
Selects data
filename = “data/walmart_store_openings.csv” chart_filename = "Walmart " + str(datetime.now())
df = pd.read_csv(filename, encoding = “utf-8-sig”)
#df #print(df.columns)
Gets list of years
years = [str(i) for i in range(1962,2007)]
Bug with Grid parsing if dataset isn’t sanitized, need to return NaN instead of empty []
#years = df[“YEAR”].unique() #years = [str(i) for i in sorted(years)]
Groups by year and count number of stores
ylist = df.groupby(“YEAR”).count()[“storenum”].astype(int) ylist_cum = ylist.cumsum()
Gets max range for subplot (minimum set to 0, no y-axis jump)
max_range = max(ylist) * 1.15 max_range_cum = max(ylist_cum) * 1.15
Converts list items to string
ylist = [str(i) for i in ylist] ylist_cum = [str(i) for i in ylist_cum]
In[]:
Uploads all 2 Grids
Since Grid has a size limit, it is good practice to upload
multiple Grids for suplots in case of large datasets
grid_filename = chart_filename + " Grid" grid_filename2 = grid_filename + “2”
columns = [] columns2 = []
for i, year in enumerate(years):
Will throw error if file exists or path is not root
grid = Grid(columns) py.grid_ops.upload(grid, grid_filename, auto_open=False)
grid2 = Grid(columns2) py.grid_ops.upload(grid2, grid_filename2, auto_open=False)
In[]:
Creates data
Main trace
trace1 = Scattermapbox(
)
Non-cumulative secondary
trace2 = Scatter(
)
Cumulative secondary
trace3 = Scatter(
)
Note that subplots are mapped to opposite yaxis (temporary solution, bugfix impending)
In[]:
Sets up slider and buttons
slider = dict(
)
sliders = dict(
)
for year in years:
updatemenus = dict(
)
In[]:
Creates layout
layout = dict(
)
In[]:
Creates frames
frames = []
for i, year in enumerate(years):
In[]:
Uploads animation
data = [trace1, trace2, trace3] figure = dict(data=data, layout=layout, frames=frames) py.icreate_animations(figure, filename=chart_filename, auto_open=False)