Gnuplot canvas: tics disappear on zoom

I have been working for a while on a web interface related to my work. I have some data that I fit with a model iteratively. In every iteration I create a Gnuplot figure that goes online to help me keep track of the process. It works very well, however, I have some minor problems related to the canvas terminal that I couldn't fix for a long time. I use Gnuplot 4.6.5 and several browsers. They all behave consistently.

Here is an example of such a page, with two figures: http://stelweb.asu.cas.cz/~nemeth/xtgrid_log/xtgrid_008_r1458384bfCsdd_dat.html

I have a struggle with the x-axis tics and resolution, and I think these problems may be related:

1 - x-axis coordinate below the figure does not show decimals. I think the x coordinate is truncated by Gnuplot.

2 - Axis tics disappear when we zoom in.

3 - I have some labels defined with: "set label at x,screen 0.2 '...some label...' " These labels disappear when zooming in, even though they are set to the screen y coordinate (0.2).

4 - Zoom resets in figure 1 when mouse is moved over to figure 2 and back to 1 again. This might be a html/java issue.

A Gnuplot script to generate these figures looks like this:

set encoding iso_8859_1
set terminal canvas solid butt size 1024,410 name figure1  mousing lw 0.7 
set output "figure1.js"
set samples 50, 50
set size ratio 0.4
set xtics autofreq 200
set mxtics 4
set xr [4000:5000]
set ylab "Relative flux"
set xlab "Wavelength (\305)"
set format y "%1.1e"
load 'lines.gnp' # just a bunch of labels
plot " ... some file ... "

I wonder if there is a general fix to these inconveniences.

To problem #4: The Gnuplot generated javascript starts like this:

function ALue310128bfCsdd_dat_7_0() 
  {
  canvas = document.getElementById("ALue310128bfCsdd_dat_7_0");
  ctx = canvas.getContext("2d");
  // Reinitialize mouse tracking and zoom for this particular plot
  if ((typeof(gnuplot.active_plot) == "undefined" || gnuplot.active_plot != ALue310128bfCsdd_dat_7_0)  &&  typeof(gnuplot.mouse_update) != "undefined")
    {
    gnuplot.active_plot_name = "ALue310128bfCsdd_dat_7_0";
    gnuplot.active_plot = ALue310128bfCsdd_dat_7_0;
    canvas.onmousemove = gnuplot.mouse_update;
    canvas.onmouseup = gnuplot.zoom_in;
    canvas.onmousedown = gnuplot.saveclick;
    canvas.onkeypress = gnuplot.do_hotkey;
    if (canvas.attachEvent) {canvas.attachEvent('mouseover', ALue310128bfCsdd_dat_7_0);
    }
  else if (canvas.addEventListener) 
    {canvas.addEventListener('mouseover',   ALue310128bfCsdd_dat_7_0, false);}
  gnuplot.zoomed = false;
  gnuplot.zoom_axis_width = 0;
  gnuplot.zoom_in_progress = false;
  gnuplot.polar_mode = false;
  ctx.clearRect(0,0,1280,513);
  }

The gnuplot.zoomed and gnuplot.zoom_in_progress variables seem like they have something to do with the reinitialization of the zoom level.

Upvotes: 1

Views: 775

Answers (1)

Christoph
Christoph

Reputation: 48430

  1. If you mean the coordinates of the mousebox: For e.g. wxt the format of these mouse coordinates is adaptable with set mouse format. That doesn't work for the canvas terminal, might be a bug.

  2. After gnuplot created the image the axis tics become only lines, i.e. the axis tics aren't regenerated when zooming. Try e.g. to zoom in around a tic: this will become very large.

  3. Same as 2.: The screen coordinates are recognized as such only within gnuplot. After being written to the file there are only absolute coordinates. If the label coordinates fall into the zoom area, the respective label is drawn, otherwise not.

  4. This might be a bug and can also be observed on e.g. http://gnuplot.sourceforge.net/demo_canvas_5.0/finance.html

I think 1. and 4. could be bugs, 2. and 3. are limits of the interactivity currently provided, and probably also limitations of gnuplot as such to produce such images.

Maybe its worth for you testing gnuplot-JS (demo at http://gnuplot.respawned.com/). I haven't tried it, yet.

Upvotes: 1

Related Questions