Bar Plot from a dictionary with tuple keys
up vote
3
down vote
favorite
I have a dictionary with tuple as keys, like shown below:
('Friday', 0): 108, ('Friday', 1): 110, ('Friday', 2): 75, ... ('Sunday', 23): 120
I`m trying to build a Bar plot, that with the dictionary keys in x axis and dictionary values in Y axis:
trace0 = go.Bar(
x=pump_dry_day_beh_dic.keys(),
y=pump_dry_day_beh_dic.values(),
name ='yyy'
)
fig = tools.make_subplots(rows=1, cols=1, specs=[[]],
shared_xaxes=True, shared_yaxes=True,
vertical_spacing=0.001)
fig.append_trace(trace0, 1, 1)
fig.append_trace(trace1, 1, 1)
fig['layout'].update(height=600, width=1000, title='xxx')
fig['layout']['xaxis1'].update(title='day-hour')
fig['layout']['yaxis1'].update(title='Values')
plotly.offline.iplot(fig, filename=' xxx')
But I`m getting the following error:
The 'x' property is an array that may be specified as a tuple,
list, numpy array, or pandas Series
On the other hand, if I change the above code to the code below, I have as result an empty plot.
x=list(pump_dry_day_beh_dic.keys()),
y=list(pump_dry_day_beh_dic.values()),
name ='yyyy'
Is there a way how I can solve this?
Thank you,
python pandas bar-chart plotly
add a comment |
up vote
3
down vote
favorite
I have a dictionary with tuple as keys, like shown below:
('Friday', 0): 108, ('Friday', 1): 110, ('Friday', 2): 75, ... ('Sunday', 23): 120
I`m trying to build a Bar plot, that with the dictionary keys in x axis and dictionary values in Y axis:
trace0 = go.Bar(
x=pump_dry_day_beh_dic.keys(),
y=pump_dry_day_beh_dic.values(),
name ='yyy'
)
fig = tools.make_subplots(rows=1, cols=1, specs=[[]],
shared_xaxes=True, shared_yaxes=True,
vertical_spacing=0.001)
fig.append_trace(trace0, 1, 1)
fig.append_trace(trace1, 1, 1)
fig['layout'].update(height=600, width=1000, title='xxx')
fig['layout']['xaxis1'].update(title='day-hour')
fig['layout']['yaxis1'].update(title='Values')
plotly.offline.iplot(fig, filename=' xxx')
But I`m getting the following error:
The 'x' property is an array that may be specified as a tuple,
list, numpy array, or pandas Series
On the other hand, if I change the above code to the code below, I have as result an empty plot.
x=list(pump_dry_day_beh_dic.keys()),
y=list(pump_dry_day_beh_dic.values()),
name ='yyyy'
Is there a way how I can solve this?
Thank you,
python pandas bar-chart plotly
add a comment |
up vote
3
down vote
favorite
up vote
3
down vote
favorite
I have a dictionary with tuple as keys, like shown below:
('Friday', 0): 108, ('Friday', 1): 110, ('Friday', 2): 75, ... ('Sunday', 23): 120
I`m trying to build a Bar plot, that with the dictionary keys in x axis and dictionary values in Y axis:
trace0 = go.Bar(
x=pump_dry_day_beh_dic.keys(),
y=pump_dry_day_beh_dic.values(),
name ='yyy'
)
fig = tools.make_subplots(rows=1, cols=1, specs=[[]],
shared_xaxes=True, shared_yaxes=True,
vertical_spacing=0.001)
fig.append_trace(trace0, 1, 1)
fig.append_trace(trace1, 1, 1)
fig['layout'].update(height=600, width=1000, title='xxx')
fig['layout']['xaxis1'].update(title='day-hour')
fig['layout']['yaxis1'].update(title='Values')
plotly.offline.iplot(fig, filename=' xxx')
But I`m getting the following error:
The 'x' property is an array that may be specified as a tuple,
list, numpy array, or pandas Series
On the other hand, if I change the above code to the code below, I have as result an empty plot.
x=list(pump_dry_day_beh_dic.keys()),
y=list(pump_dry_day_beh_dic.values()),
name ='yyyy'
Is there a way how I can solve this?
Thank you,
python pandas bar-chart plotly
I have a dictionary with tuple as keys, like shown below:
('Friday', 0): 108, ('Friday', 1): 110, ('Friday', 2): 75, ... ('Sunday', 23): 120
I`m trying to build a Bar plot, that with the dictionary keys in x axis and dictionary values in Y axis:
trace0 = go.Bar(
x=pump_dry_day_beh_dic.keys(),
y=pump_dry_day_beh_dic.values(),
name ='yyy'
)
fig = tools.make_subplots(rows=1, cols=1, specs=[[]],
shared_xaxes=True, shared_yaxes=True,
vertical_spacing=0.001)
fig.append_trace(trace0, 1, 1)
fig.append_trace(trace1, 1, 1)
fig['layout'].update(height=600, width=1000, title='xxx')
fig['layout']['xaxis1'].update(title='day-hour')
fig['layout']['yaxis1'].update(title='Values')
plotly.offline.iplot(fig, filename=' xxx')
But I`m getting the following error:
The 'x' property is an array that may be specified as a tuple,
list, numpy array, or pandas Series
On the other hand, if I change the above code to the code below, I have as result an empty plot.
x=list(pump_dry_day_beh_dic.keys()),
y=list(pump_dry_day_beh_dic.values()),
name ='yyyy'
Is there a way how I can solve this?
Thank you,
python pandas bar-chart plotly
python pandas bar-chart plotly
edited Nov 9 at 20:40
petezurich
3,34381632
3,34381632
asked Nov 9 at 19:41
onra
1109
1109
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
3
down vote
accepted
Since you have pandas
tag here...
import pandas as pd
pump_dry_day_beh_dic = ('Friday', 0): 108, ('Friday', 1): 110,
('Friday', 2): 75, ('Sunday', 23): 120
pd.DataFrame([pump_dry_day_beh_dic]).T.plot.bar()
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
Since you have pandas
tag here...
import pandas as pd
pump_dry_day_beh_dic = ('Friday', 0): 108, ('Friday', 1): 110,
('Friday', 2): 75, ('Sunday', 23): 120
pd.DataFrame([pump_dry_day_beh_dic]).T.plot.bar()
add a comment |
up vote
3
down vote
accepted
Since you have pandas
tag here...
import pandas as pd
pump_dry_day_beh_dic = ('Friday', 0): 108, ('Friday', 1): 110,
('Friday', 2): 75, ('Sunday', 23): 120
pd.DataFrame([pump_dry_day_beh_dic]).T.plot.bar()
add a comment |
up vote
3
down vote
accepted
up vote
3
down vote
accepted
Since you have pandas
tag here...
import pandas as pd
pump_dry_day_beh_dic = ('Friday', 0): 108, ('Friday', 1): 110,
('Friday', 2): 75, ('Sunday', 23): 120
pd.DataFrame([pump_dry_day_beh_dic]).T.plot.bar()
Since you have pandas
tag here...
import pandas as pd
pump_dry_day_beh_dic = ('Friday', 0): 108, ('Friday', 1): 110,
('Friday', 2): 75, ('Sunday', 23): 120
pd.DataFrame([pump_dry_day_beh_dic]).T.plot.bar()
answered Nov 9 at 19:50
ysakamoto
2,0741719
2,0741719
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53232295%2fbar-plot-from-a-dictionary-with-tuple-keys%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown