Winston.jl icon indicating copy to clipboard operation
Winston.jl copied to clipboard

no plot window with oplot

Open XilinJia opened this issue 10 years ago • 6 comments

Demonstrated with the following code to plot multiple curves (Is this the right way to do it?). The plot window does not show, but with file("figure.png") the plots are saved to the file.

julia> Pkg.build("Winston")
INFO: Building Cairo
INFO: Building Tk

--------------------
using Winston
pw = FramedPlot()

for fname in fnames
    mydata = readcsv(pathname * fname)
    CumRet = mydata[:, 3]   

    x1 = [1:length(CumRet)]
    oplot(x1, CumRet)
end

XilinJia avatar Apr 11 '14 04:04 XilinJia

See http://winston.readthedocs.org/en/latest/fun/oplot.html

oplot is used to add (overplot) things into an existing plot. First you have to create the plot by using the plot command. Other option is to use the hold http://winston.readthedocs.org/en/latest/fun/hold.html

natj avatar Apr 11 '14 17:04 natj

Actually, this is a different problem: http://winston.readthedocs.org/en/latest/faq.html#why-is-nothing-displayed-when-i-call-plot-in-a-script

You can work around this by replacing pw = FramedPlot() with pw = plot(), and then calling display(pw) after the for loop. But i need to come up with a better solution to this.

nolta avatar Apr 11 '14 18:04 nolta

Ah sorry, my bad. However, what comes to the current repl vs script behaviour it is in my opinion, quite reasonable. Usually if I have a longer script that I run separately it also has many plot-calls that are to be saved in files. In this case it would not work to have many plot windows flashing on the screen. If I then want to explicitly see the window, I just specify it with the display command.

For some reason this seems to raise lot of questions tho, so obviously something needs to be done. Maybe highlight this more in the manual?

natj avatar Apr 11 '14 18:04 natj

Yeah, i don't want to change the current script behavior. But i do want to reduce the number of times that the repl doesn't appear to do anything.

nolta avatar Apr 11 '14 18:04 nolta

yeah! use "display" will show the image !!!

i tried many things...

does it ok to add "display" or something else to readme?

yfractal avatar Apr 12 '14 03:04 yfractal

In the REPL I need to do use display to see something with plot, both on windows and os x, is that the normal behavior or is it a bug ?

Staross avatar Apr 22 '14 08:04 Staross