/ sherpa4.16 / faq / add_plot_line_mpl.html
This page is for the obsolete Sherpa 4.16 release. Please see the Sherpa home page for the latest release.
Adding a line to a plotĀ
Matplotlib has a number of ways to add lines toa plot. For this example we shall use a simple histogrammed dataset
sherpa> load_arrays(1, [1, 5, 8], [5, 7, 10], [20, 30, 25]) sherpa> prefs = get_plot_prefs("data") sherpa> prefs["linestyle"] = "solid" sherpa> prefs["yerrorbars"] = False sherpa> plot_data()
Figure 1: the original plot
A number of Matlpotlib commands can be used to add lines to a plot.
sherpa> plot_data()
For example, horizontal and vertical lines can be added that cover the whole plot:
sherpa> plt.axhline(22, c="g", alpha=0.5) sherpa> plt.axvline(7.5, c="k")
A line that crosses two points can also be added:
sherpa> plt.axline((2, 21), (10, 29), ls="dotted", lw=2)
Figure 2: adding lines
/ sherpa4.16 / faq / add_plot_line_mpl.html