Zoom out in Octave / gnuplot - octave

I use Octave with gnuplot under Windows.
I can zoom in using the right mouse button. But how can I zoom out from the UI?

I found this post on Nabble. Pressing p takes you to the previous zoom level, n to the next level, and u unzooms. I pressed h in a gnuplot window outside of Octave and got this command list:
2x<B1> print coordinates to clipboard using `clipboardformat`
(see keys '3', '4')
<B2> annotate the graph using `mouseformat` (see keys '1', '2')
or draw labels if `set mouse labels is on`
<Ctrl-B2> remove label close to pointer if `set mouse labels` is on
<B3> mark zoom region (only for 2d-plots and maps).
<B1-Motion> change view (rotation). Use <ctrl> to rotate the axes only.
<B2-Motion> change view (scaling). Use <ctrl> to scale the axes only.
<Shift-B2-Motion> vertical motion -- change xyplane
Space raise gnuplot console window
q * close this plot window
a `builtin-autoscale` (set autoscale keepfix; replot)
b `builtin-toggle-border`
e `builtin-replot`
g `builtin-toggle-grid`
h `builtin-help`
l `builtin-toggle-log` y logscale for plots, z and cb for splots
L `builtin-nearest-log` toggle logscale of axis nearest cursor
m `builtin-toggle-mouse`
r `builtin-toggle-ruler`
1 `builtin-decrement-mousemode`
2 `builtin-increment-mousemode`
3 `builtin-decrement-clipboardmode`
4 `builtin-increment-clipboardmode`
5 `builtin-toggle-polardistance`
6 `builtin-toggle-verbose`
7 `builtin-toggle-ratio`
n `builtin-zoom-next` go to next zoom in the zoom stack
p `builtin-zoom-previous` go to previous zoom in the zoom stack
u `builtin-unzoom`
Right `builtin-rotate-right` only for splots; <shift> increases amount
Up `builtin-rotate-up` only for splots; <shift> increases amount
Left `builtin-rotate-left` only for splots; <shift> increases amount
Down `builtin-rotate-down` only for splots; <shift> increases amount
Escape `builtin-cancel-zoom` cancel zoom region
* indicates this key is active from all plot windows

https://www.gnu.org/software/octave/doc/v4.0.1/Introduction-to-Plotting.html
I use graphics_toolkit ("fltk") to zoom plots for octave running on linux.

Related

pyautogui / pyscreeze - locate works w/o region parameter, but doesn't work w/ region parameter

Using pyautogui, I'm trying to locate an image on screen.
This finds the image (on primary monitor w/ 2560x1440 resolution), but takes nearly 5 sec:
icon1 = pyautogui.locateOnScreen('[filepath]\\icon1.png', grayscale=True)
To reduce search time, I provide a region parameter, but this doesn't find the image. It executes in ~0.7 sec
icon1 = pyautogui.locateOnScreen('[filepath]\\icon1.png', region=(1500,100,950,1100), grayscale=True)
Eliminating the grayscale parameter doesn't change the result - still ~0.7 execution time and image not found:
icon1 = pyautogui.locateOnScreen('[filepath]\\icon1.png', region=(1500,100,950,1100))
Then I tried setting the region parameter to the entire screen, but image not found and execution time is ~1.5sec, so it's searching (judging by longer execution time w/ larger region), just not finding.
icon1 = pyautogui.locateOnScreen('[filepath]\\icon1.png', region=(0,0,2559,1439))
Any suggestions on what to try next? Thanks.
I figured out what's happening. As a preface, I am working with multiple monitors, and have made modifications to pyautogui and pyscreeze as described in these 2 pyautogui github comments:
https://github.com/asweigart/pyautogui/issues/9#issuecomment-527236475
https://github.com/asweigart/pyautogui/issues/321#issuecomment-629819495
With these modifications, pyautogui works with multiple monitors, and pyautogui.position() and pyautogui.moveTo() treat the upper left corner of the primary monitor as coordinate (0,0) - this means monitors above or to the left of primary monitor will have at least one negative coordinate.
But pyscreeze is returning image search results based on treatment of the upper left corner of the upper left monitor as coordinate (0,0) - so all coordinates on extended desktop are positive.
The region parameter I was passing to locateOnScreen() was based on using pyautogui.position() reported coordinates, so the search was being executed on an incorrect area of the screen.
Once I figured that out, I was able to pass the correct region specification.
To illustrate, I inserted a print statement in pyscreeze to show where the image is found. And a print of the image search return. And in my code, I printed pyautogui.position().
retVal = Box(left=8008, top=3171, width=29, height=31)
Point(x=4182, y=1026)
mouse position:
Point(x=4182, y=1026)
So you can see that coordinates are quite different. Pyscreeze is showing coordinates based on 0,0 being upper left corner of upper left monitor, while the image search return variable are coordinates based on 0,0 being upper left corner of primary monitor, so I'm able to take the image search result variable and pass that to pyautogui.moveTo() and move the mouse there (moveTo needs coordinates based on 0,0 being upper left corner of primary monitor).
The issue stems from adopting changes from two different people to pyautogui and pyscreeze. I suppose I could adjust the changes to one of these packages to offset the coordinates so that both are referencing the same monitor's upper left corner as coordinate (0,0).
Your region is set wrong. Use (0,0,2559,1439).
And if this doesn't work make a new screenshot specifying the region for it, save it and look if that just captured screenshot would be found on the screen.
The code below should always work as expected:
from time import perf_counter as T
import pyautogui
# NOTICE that in pyautogui: region=(left, top, width, height)
pyautogui.screenshot('pyautogui_region_screenshot.png', region=(300, 500, 300, 200))
sT = T()
img = pyautogui.locateOnScreen('pyautogui_region_screenshot.png', region=(300, 500, 300, 200))
eT = T()
print(f'img = pyautogui.locateOnScreen took: {eT-sT:9.5f} seconds')
print(img)
By the way: check out https://stackoverflow.com/questions/72410958/taking-a-screenshot-of-a-specific-portion-of-the-screen-in-python to switch to another Python module ( mss ) for doing screenshots of small regions of the screen.
https://pyautogui.readthedocs.io/en/latest/screenshot.html

Calculating how many shapes of specific size fit inside polygon on Google Maps

I would like the user to draw a polygon shape on google maps - this isnt an issue and have this sorted.
When the user then clicks a button, I need to work out how many rectangular shapes of a specific size will fit inside this polygon.
The issue I have is if the polygon is for example 6m x 4m and the shape that needs to fit is 2m x 3m, then you can only fit 3 shapes (area totalling 6m x 3m if the shapes are side by side) and leaves 6m x 1m area remaining.
The remaining area is the same area as the shape, but its the wrong size.
How do I see how many "whole" shapes fit inside the polygon?
I will upload an image to show what I mean
This is actually a difficult problem a particular case of a packing problems a full solution would turn out to be quite complex, possibly NP-hard.
It should be fairly easy to derive a sub-optimal solution. We can consider two possible solutions with the rectangles horizontal or vertical with them in a uniform grid.
Let the size of the big rectangle be A X B and the small rectangle be a X b. For the unrotated version we can fit m=floor(A/a) horizontally and n=floor(B/b) vertically giving a total of n*m items fitted in. Rotating by 90ยบ we have p=floor(A/b) and q=floor(B/a) with a total of p*q items.
There will be some which the above does not give the best solution, say a fitting 2X3 rectangles into 5 X 4. If two are horizontal and one is vertical then you can fit 3 in.
For an irregular polygon boundary you could arrange them in rows with the distance between each row equal to the height of the smaller rectangles.
A pseudocode solution might work something like
poly = getPolygon() // get the input polygon
a = rectangle.height // size of rectangle we are trying to fit
b = rectangle.width // size of rectangle
row_height = 10
bounds = poly.getBoundingBox()
offset_top = a/2 // y coord of the first row
// loop from top to bottom
for(y = bounds.top + offset_top ; y < bounds.bottom; y += a )
{
// find all the solutions of the polygon with a horizontal line
sols1 = poly.intersectWithHorizontalLine(y)
// find sols of bottom line
sols2 = poly.intersectWithHorizontalLine(y+a)
// find the left most and right most points
left = min(sols1,sols2)
right = max(sols1,sols2)
// now can draw the rectangles
for(x=left; x < right; x += b)
{
drawRectangle( x , y, width=b, height=a)
}
}

mouse in gnuplot x11

I noticed that I can use the right button of the mouse in order to zoom in a plot in gnuplot, with the terminal X11.
I don't find any documentation for the other mouse gesture.
For example, it would be fine to do some zoom out!
Could you suggest this?
Best,
Al.
EDIT:
Apparently, the only possibility is to zoom in with the right mouse button and use the key p to come back, as Christoph suggested.
Yes, the documentation is not very clear about this. You can find some information about this under help mouse (type this in the interactive gnuplot terminal, or see the section Mouse in the pdf). This shows you for example, that you can use the mouse wheel for scrolling in x and y direction as well as zooming (help mouse scrolling).
To get all the gestures, type show bind, which gives me (Linux, 4.6.4):
gnuplot> show bind
2x<B1> print coordinates to clipboard using `clipboardformat`
(see keys '3', '4')
<B2> annotate the graph using `mouseformat` (see keys '1', '2')
or draw labels if `set mouse labels is on`
<Ctrl-B2> remove label close to pointer if `set mouse labels` is on
<B3> mark zoom region (only for 2d-plots and maps).
<B1-Motion> change view (rotation). Use <ctrl> to rotate the axes only.
<B2-Motion> change view (scaling). Use <ctrl> to scale the axes only.
<Shift-B2-Motion> vertical motion -- change xyplane
<wheel-up> scroll up (in +Y direction).
<wheel-down> scroll down.
<shift-wheel-up> scroll left (in -X direction).
<shift-wheel-down> scroll right.
<control-wheel-up> zoom in toward the center of the plot.
<control-wheel-down> zoom out.
<shift-control-wheel-up> zoom in only the X axis.
<shift-control-wheel-down> zoom out only the X axis.
Space raise gnuplot console window
q * close this plot window
a `builtin-autoscale` (set autoscale keepfix; replot)
b `builtin-toggle-border`
e `builtin-replot`
g `builtin-toggle-grid`
h `builtin-help`
l `builtin-toggle-log` y logscale for plots, z and cb for splots
L `builtin-nearest-log` toggle logscale of axis nearest cursor
m `builtin-toggle-mouse`
r `builtin-toggle-ruler`
1 `builtin-previous-mouse-format`
2 `builtin-next-mouse-format`
3 `builtin-decrement-clipboardmode`
4 `builtin-increment-clipboardmode`
5 `builtin-toggle-polardistance`
6 `builtin-toggle-verbose`
7 `builtin-toggle-ratio`
n `builtin-zoom-next` go to next zoom in the zoom stack
p `builtin-zoom-previous` go to previous zoom in the zoom stack
u `builtin-unzoom`
Right `builtin-rotate-right` only for splots; <shift> increases amount
Up `builtin-rotate-up` only for splots; <shift> increases amount
Left `builtin-rotate-left` only for splots; <shift> increases amount
Down `builtin-rotate-down` only for splots; <shift> increases amount
Escape `builtin-cancel-zoom` cancel zoom region
I know this is an old post, but I've been having the trouble of the graph being too large for the gnuplot window (Version 4.6 patchlevel 6).
The solution I found was to hold down the scroll wheel and pan left or right to zoom out and in respectively.
Hope it helps.

gnuplot how to zoom y & y2 axis

I have a plot like this using wgnuplot:
the green and blue are on y2 axis.
Question 1:
When I zoom using right mouse button I get:
The black line on yaxis is to compressed near top. How can I get the y scale to fit the data for this window at this point AUTOMATICALLY. I.e.e without me having to type range commands?
Questions 2:
Again, is there anyway to rescale/zoom the y2axis ALONE, by mouse?
Just press 'a' or click the autoscale button to adjust the y-scale. Maybe you want to use set autoscale xfix before that.
Its not by mouse, but you can use the bind command to rescale only the y2-axis with the hotkeys 'alt-z' and 'alt-y':
bind 'alt-z' 'set y2range[GPVAL_Y2_MIN*2:GPVAL_Y2_MAX*2]; replot'
bind 'alt-y' 'set y2range[GPVAL_Y2_MIN*0.5:GPVAL_Y2_MAX*0.5]; replot'

Translating flash info box into coordinates for html5 canvas shape?

I'm trying to recreate some flash shapes that appear on rollover upon a circle symbol. I'm needing to convert flash x and y points to the canvas coordinate grid. I figured out how to convert the circle coord points. However, the info I'm given for the shapes that appear on rollover make no sense to me.
For example, take this rollover point, where the dimensions refer to the registration point (little cross in the upper left):
x = 532.30
y = 30.35
w/h = 19.80
But based off this, the info I get for the rectangle that appears on rollover makes no sense:
x = -7.30
y = 17.30
w = 29.0
h = 16.5
I figured this meant that the rectangle's upper left point was 7.30 pixels to the left, and 17.30 pixels down from the registration point of the circle. Is that right? What origin are these x and y coordinates based off of?
The width and height are completely confusing to me though. The given width is 29.0, but this can't be right. If I get x and y coordinates just using my cursor, its clear that the rectangle is much wider than this:
564 - 521 = 43
43 != 29
Please help me understand the mysterious info box I'm being presented with for this rectangle. I just need to get some vanilla coordinates for it so I can draw it on the HTML5 canvas.
What origin are these x and y coordinates based off of?
These x and y coordinates are based off of the registration point of tab button.
43 != 29
When you work with symbols on a stage, the symbols that you're working with aren't the actual original Library symbol. They're copies that can be manipulated by scaling them, applying color and opacity effects and...
This instance of tab button is scaled, if you open library panel and edit tab symbol you can see the actual size.
UPDATE
after I change width and height of tab button to 19.80:
29*(150/100)=43.5