Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
551 views
in Technique[技术] by (71.8m points)

python - How to plot vertical line from x axis to plotted line?

I am trying to add a vertical line on my plot that starts on the x axis and ends on the plotted line using matplotlib but I don't find the right solution.

My MWE has 3 subplots. The question concerned the red and the green lines. I would like to have a vertical line starting like the red one and ending like the green one. How could I do that?

I also would like to add a xtick and an ytick on each axis with the value of vertical and horizontale lines.

from scipy import signal
import matplotlib.pyplot as plt

sys = signal.TransferFunction([1], [1, 1])
w, mag, phase = signal.bode(sys)

fig, axs = plt.subplots(3, 1, sharex=True)
fig.subplots_adjust(hspace=0)
axs[0].semilogx(w, mag)
axs[1].semilogx(w, phase)
axs[1].axhline(y=-40., xmax=1,color='grey')
axs[1].axvline(x=.85, color='red')
axs[2].semilogx(w, phase)
axs[2].axhline(y=-40., xmax=1,color='grey')
axs[2].vlines(.85, axs[2].get_ylim()[0], -40., color='green')

plot

question from:https://stackoverflow.com/questions/65904867/how-to-plot-vertical-line-from-x-axis-to-plotted-line

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...