Advertisement
sunsexsurf

Scatter + Bar plots

Oct 24th, 2020 (edited)
500
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.16 KB | None | 0 0
  1. fig = make_subplots(specs=[[{"secondary_y": True}]])
  2.  
  3.  
  4. trace0 = go.Scatter(x=df.index,
  5.                     y=df.gold,
  6.                     name="Золото",
  7.                     line=dict(color='#f5c541'),
  8.                     yaxis='y1')
  9.  
  10. trace1 = go.Bar(x=sell_silver.index, # assign x as the dataframe column 'x'
  11.                 y=sell_silver['Реализовано'],
  12.                 name = 'Реализовано',
  13.                 marker=dict(
  14.                     color='green',
  15.                     opacity=0.1,
  16.                     line=dict(
  17.                         color='black',
  18.                         width=2
  19.                     )
  20.                 ),
  21.                 yaxis='y2',
  22. #                 width=0.01
  23.                )
  24.  
  25. trace2 = go.Bar(x=sell_silver.index, # assign x as the dataframe column 'x'
  26.                 y=sell_silver['Тираж'],
  27.                 name = 'Тираж',
  28.                 marker = dict(
  29.                     color='red',
  30.                     opacity=0.1,
  31.                     line=dict(
  32.                         color = 'black',
  33.                         width=2)
  34.                 ),
  35.                 yaxis='y2',
  36. #                 width=0.01,
  37.           )
  38.  
  39.  
  40. fig.add_trace(trace0,
  41.               secondary_y=True)
  42. fig.add_trace(trace1,
  43.               secondary_y=False)
  44. fig.add_trace(trace2,
  45.               secondary_y=False)
  46.  
  47.  
  48.  
  49. fig.update_layout(
  50. #     barmode='stack',    
  51.     barmode='relative',
  52.     plot_bgcolor='rgba(0,0,0,0)',
  53.     title_text="Серебро (2018 - 2020 год)",
  54.     title_x = 0.5,
  55.     width=1024,
  56.     height=600,
  57.     legend=dict(x=.45,
  58.                 xanchor="center",
  59.                 orientation="h"))
  60.  
  61. # Set x-axis title
  62. fig.update_xaxes(title_text="<b>Годы</b>",
  63.                  gridcolor='lightblue')
  64.  
  65. # Set y-axes titles
  66.  
  67. fig.update_yaxes(title_text="<b>Цена на серебро</b> (р./грамм)",
  68.                  secondary_y=True,
  69. #                  gridcolor='#f5c541'
  70.                 side='left')
  71.  
  72. fig.update_yaxes(title_text="<b>Шт.</b>",
  73.                  secondary_y=False,
  74.                  gridcolor='#1167b1',
  75.                  side='right')
  76.  
  77. fig.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement