0

I have a plot that I have created as such using a vector c

hist_c=histogram(c,binsize=0.002,locations=locs_c,min=0.000,max=1.000)
pdf_c=float(hist_c)/n_elements(c)
ppdf_c=plot(locs_c,pdf_c,xtitle='c',ytitle='freq')

I would like to add the vertical line x=0.92 over the line plot I created. The function oplot requires an array, so I am not sure how I can do this.

Bereket
  • 55
  • 8

1 Answers1

1

Typically, you create simple arrays to plot:

xvalue = 0.92
line = plot(fltarr(2) + xvalue, ppdf_c.yrange, /overplot)

where xvalue is the x-coordinate of your vertical line and ppdf_c is the reference to your last plot.

For reference for those using direct graphics, this would be how to do it in direct graphics:

xvalue = 0.92
oplot, fltarr(2) + xvalue, !y.crange
mgalloy
  • 2,356
  • 1
  • 12
  • 10
  • your code works fine, but the line is drawn in a different window. The code works if I had done `plot, locs_c, pdf_c, xtitle='c', ytitle='freq'` but writing the code as I did in my first post plots the graph in a window containing different tools and the line in a simplified window. How can I have them appear in the same window? – Bereket Jun 11 '20 at 04:15
  • 1
    Sorry, I didn't realize you were using function graphics. I will revise my answer to work for function graphics instead of direct graphics. – mgalloy Jun 11 '20 at 16:30