Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

stock chart w/ two y axes

Help
Jozef Riha
2005-05-15
2013-02-10
  • Jozef Riha
    Jozef Riha
    2005-05-15

    hello,

    i am trying to create a stock chart w/ two y axes (quote and share volume). i've got the following code:

    set xdata time                                                                     
    set timefmt "%d.%m.%y"                                                              
    set key default                                                                     
    set xrange [1 : 250]                                                                
    set x2range [1 : 250]                                                               
    set ytics nomirror                                                                  
    set y2tics                                                                          
    set tics out                                                                        
    set autoscale y                                                                     
    set autoscale y2                                                                    
    plot 'cez.csv' using 1:3, 'cez.csv' using 1:5 axes x2y2                             
    pause 10

    data look like this:
    1       29.12.2003      145,25  "1.68% "        1812195 "143.30"        "2.50%" 2488    37984

    the code however does not work unless i comment the first line (xdata time) if the line remains uncommented gnuplot (4.0) produces the following error message:

    all points y value undefined!

    please how to fix this?

    thank you.

    cheers,

    -- joe

     
    • The problem are the 'set xrange' and 'set  x2range' statements in your script.  Delete them and the script should work.  For a stock chart with 2 y axes, you almost certainly don't want to use 2 xrange --- it should be using 'axes x1y2'.

      There other problems: the 'using' column number for the date appears to be wrong, and the ',' in the decimal fractions will confuse gnuplot.  Translate it to '.'.

       
      • Jozef Riha
        Jozef Riha
        2005-05-16

        thank you. it did help. however i am experiencing one other problem not related to the two axes.. the code i have:

        set xdata time                                                                                                        
        set timefmt "%d.%m.%y"                                                                                                
        set xrange ["5.1.2003" : "31.12.2005"]                                                                                
        set x2range ["5.1.2003" : "31.12.2005"]                                                                               
        set ytics nomirror                                                                                                    
        set tics out                                                                                                          
        set autoscale y                                                                                                       
        set yrange [85:500]                                                                                                   
        set format x "%m"                                                                                                     
        set term postscript eps color solid "Time-Roman" 24                                                                   
        set output "m.eps"                                                                                                    
        set size 2,2                                                                                                          
        plot 'cez.dat' using 1:2 with lines lt 1 lw 4                                                                         
        replot

        the problem is that the data is displayed using 1-year long scale in multiple rows (1 row per year). i am able to read the values for years 2003--2005(may) however i'd be happier w/ a plot shown in one row.

        is there a way to?

        thank you.

        cheers,

        -- joe

         
        • Read the help on 'timefmt' again, and note the difference between %y and %Y.