Home > OS >  Plotly: How to plot Horizontal line Between "2 Points" where points on x axis are Months
Plotly: How to plot Horizontal line Between "2 Points" where points on x axis are Months

Time:01-15

Is there a way to control the starting and ending points of horizontal and vertical lines in plotly?

import plotly.graph_objects as go
        
fig = go.Figure(data=go.Scatter())
fig.add_vline(x=1, line_width=2, line_dash="dash", line_color="green")
fig.add_hline(y=2, line_width=2, line_dash="dash", line_color="red")
fig.show()

Code above will plot lines but on whole screen

I want to do something like:

import matplotlib.pyplot as plt
fig, ax = plt.subplots(figsize = (10,7))

ax.hlines(y=2, xmin='July', xmax='Aug', linewidth=2, color='red', linestyles = 'dotted')
ax.axvline(x = 1,color = 'green', linestyle = 'dotted', linewidth = 2)

CodePudding user response:

From the enter image description here

  •  Tags:  
  • Related