Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. #Bar Chart
  2. #Mean house values by Bedrooms type and year
  3. import plotly.graph_objs as go
  4. import plotly.plotly as py
  5. trace1 = go.Bar(
  6. x = df_groupby_datebr.index.values,
  7. y = df_groupby_datebr.ZHVI_1bedroom,
  8. name = "ZHVI_1bedroom",
  9. marker = dict(color = 'rgb(102,255,255)'),
  10. text = df_groupby_datebr['ZHVI_1bedroom'])
  11. trace2 = go.Bar(
  12. x = df_groupby_datebr.index.values,
  13. y = df_groupby_datebr.ZHVI_2bedroom,
  14. name = "ZHVI_2bedroom",
  15. marker = dict(color = 'rgb(102,178,255)'),
  16. text = df_groupby_datebr['ZHVI_2bedroom'])
  17. trace3 = go.Bar(
  18. x = df_groupby_datebr.index.values,
  19. y = df_groupby_datebr.ZHVI_3bedroom.values,
  20. name = "ZHVI_3bedroom",
  21. marker = dict(color = 'rgb(102,102,255)'),
  22. text = df_groupby_datebr['ZHVI_3bedroom'])
  23. trace4 = go.Bar(
  24. x = df_groupby_datebr.index.values,
  25. y = df_groupby_datebr.ZHVI_4bedroom.values,
  26. name = "ZHVI_4bedroom",
  27. marker = dict(color = 'rgb(178, 102, 255)'),
  28. text = df_groupby_datebr['ZHVI_4bedroom'])
  29. trace5 = go.Bar(
  30. x = df_groupby_datebr.index.values,
  31. y = df_groupby_datebr.ZHVI_5BedroomOrMore.values,
  32. name = "ZHVI_5BedroomOrMore",
  33. marker = dict(color = 'rgb(255, 102, 255)'),
  34. text = df_groupby_datebr['ZHVI_5BedroomOrMore'])
  35. data = [trace1, trace2, trace3, trace4, trace5]
  36. layout = go.Layout(barmode = "group", title="Bar Chart: Mean House Values by Bedrooms and Year",
  37. xaxis= dict(title= 'Year',ticklen= 5,zeroline= False),
  38. yaxis= dict(title= 'Mean House Values',ticklen= 5,zeroline= False))
  39. fig = go.Figure(data = data, layout = layout)
  40. url = py.plot(fig, validate=False)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement