Hi,
I have been using Gnuplot for a while and have tried to use the mouse to manually place labels, arrows, circles rather than typing "set label at ..." type of commands for which the coordinates have to be typed. Double-clicking does place the coordinates to clipboard and I can use "pause mouse", but it would be much nicer, much more convenient if the mouse coordinates are exported when mouse is moved.
I think those coordinates are updated when mouse is moved, because we can see them on left lower corner of the plot window. So, maybe if they are exported and made available to the user with additional mouse variables?
In other words, it would be nice to be able to do something like the zoom window, when we use right-click to zoom, with labels, arrows, basically with any object. Here are the ways, I thought it could be achieved through.
Last edit: Karl Ratzsch 2014-07-02
Seriously? That is the answer to all written above?
I am in shock! Big disappointment! If the text is too cryptic you could have asked for clarification. This gives me so much motivation to get involved in this great project!
Thanks!
Hey, there was no offense intended, i was just in a hurry.
And if this isn´t what you wanted, please do clarify.
When we right-click on the plot and move the mouse until a second right-click occurs, we see that zoom box that shows us a preview of what is going to be zoomed. And that happens when mouse is moved. AFAIK, currently, MOUSE_X and MOUSE_Y are available to the user only after a mouse click as it is the case of your example code. All I am saying is why not have zoom box type of functionalities for drawing arrows, circles and so on?
Yes, MOUSE_X and MOUSE_Y are only updated at a mouseclick, but you need to click anyway to mark the beginning or end of an arrow.
;-)
If you want a user interface to draw on you plot, that would be something completely different. An UI could handle selection of items (Arrows, labels, etc. ...) and drawing, and then return the respective "set arrow ..." or similar command to gnuplot to put it on the plot.
Sure, if you call it a complete UI, I would definitely want that. I just thought it would be something too hard to implement at this point, so was just trying to offer an idea that I thought was a big step towards a UI. Because the mouse coordinates are already available internally. The status bar on the bottom displays them as the mouse moves. Plus, there is the zoom box. So, I thought, with a little more effort we can have a nice UI much better than the current state of "set object ..." commands. Entering coordinates by hand doesn't feel natural compared to clicking. I can't imagine any way "set object ..." commands can be used besides annotation purposes. So, the coordinates of labels, arrows, and such are not "data", they mean nothing in terms of data plotting. Having to enter them one by one, by typing is very cumbersome.
I probably shouldn't have mentioned exporting at all for a feature request. Because, now I am not sure how that would work anyways. Especially, if having a UI is much easier to implement. So, please, feel free to reword this request as you feel proper. Long story short, my request is a UI as you put it nicely.
Thanks!
The charm of gnuplot is (for me) to program the creation process of a graph, then execute the script, which perhaps asks for some specific interaction (as with the above examples), and then have my graph exactly as i wanted.
If im not satisfied, i adapt the script, and run it again. I can save every variable for further use, so i won´t have to redo calculations (or mouse interactions) that are already OK (you just "print 'x = ',x to a file, and "load" that the next time).
I have full control over everything in my graph, because i simply rebuild it from scratch every time.
Sorry, this turned out to be a long post, but I hope this will convey what I am trying to say. Very excited! So, here it goes.
I completely agree with everything you said. I haven't done any complicated calculations which depend on mouse interaction. But, here is where I think mouse interaction is very helpful and intuitive and still does not interfere with the workflow you described, on the contrary it supports it. I would plot my data, then look at the plot, zoom in/out, use the mouse wheel to shift right/left and up/down, decide on ranges to actually plot, decide on the title of the plot, decide legend labels for the different traces, play with linetypes, linecolors, pointstyles, pointsizes, replot adding vectors (plot with vectors), replot adding text labels from a file and so on... All these steps and additions to the plot are done at least one step at a time. Beauty of scripting! Plot many different graphs into a gif or a many-page pdf to see the subtle differences of my data. Especially with the new loops! Boy, what a luxury, compared to old days when we had to use "reread". For quite some time now, I enjoy the bind command. Here is a portion of my .gnuplot file.
k=1
bind "+" "k=k+1; rep"
bind "-" "k=k-1; rep"
bind "0" "k=1; rep"
With the interactive ability of gnuplot and these commands I can look at my data in so many ways without having to type a single command. Saves so much time and energy which I can use to do my work better.
With all this I am just trying to demonstrate that I am all for scripting, but how about adding some more ease, provide tools that make everyone's life easier when preparing and fine-tuning their scripts.
Sometimes I want to add some arrows to point out particular regions on my plots or circles or rectangles. For now it is all manual, command is "set object at X,Y" or "set object from x1,y1 to x2,y2". And where do I get those Xs and Ys? How about I just say "set arrow mouse", then I click on the plot and an arrow appears with its tail fixed at the clicked position and head moving with cursor. When I am satisfied with it I click again and the arrow stays there. Internally, gnuplot still saves the objects the same way and when I am satisfied with my plot I do 'save filename' and the arrows are fixed in their positions next time I load my script with no further mouse interaction. But, we need to get those coordinates the first time. Let's get those from the mouse is what I am saying!
OK, the "set arrow mouse" idea sounds attractive.
It might even work:
Upon "set arrow 4 mouse", the terminal returns two pairs of coordinates. Then "set arrow" stores them in variables named "MOUSEARROW_4_X1", _Y1, X2 etc. Arrow number four gets a flag "mouse", which make it read it´s position from those variables upon "reprint".
But i have an idea for a more general approach: Any object (label, etc) could have such a flag, which makes it store the variable names used for the coordinates, instead of the momentary values. Then positions (label texts, ...) would automatically update upon replot.
Then there could be a mousing command "mouse arrow variableprefix", which receives two point coordinates from the terminal and stores them in user variables, saving some typing in comparison to my above example.
OK, now that sounds a few steps ahead of what I had in mind. For what I am suggesting, I believe there is no need for a flag. I want them to be momentary values. Nothing special about the coordinates, other than that they are received from the terminal. Once I decide where to put the objects after hovering the mouse with the arrow head tied to the arrow and click (second click), that's it. That's where I want my arrow 4 to be upon replot. I am not sure what you mean by "Then positions (label texts, ...) would automatically update upon replot."