Drawing on graphs, but only within plot rectangle
BMangum
I want the lines to scale with the graph so I have used:
SetDrawEnv xcoord = bottom, ycoord=left
This mostly does what I want, however, when zooming close-in, the drawn objects now extend into the margins of the graph.
is there any way to have the drawn object scale appropriately, but only within the plot rectangle of the graph?
--Jim Prouty
Software Engineer, WaveMetrics, Inc.
June 7, 2017 at 09:39 am - Permalink
I am using your suggested work-around, which works fine for changing zoom levels but not for re-sizing a window.
Maybe something to add to the wish list.
Thanks for the suggestion though, I am making it work for now.
June 7, 2017 at 12:22 pm - Permalink
String layerName="UserBack"
Prompt layerName, "Create Mask on layer", popup, "ProgBack;UserBack;ProgAxes;UserAxes;ProgFront;UserFont;"
SetDrawLayer/K $layerName
SetDrawEnv push
SetDrawEnv xcoord=prel, ycoord=prel, linethick=0, fillfgc=(65535,65535,65535), save
DrawRect -2,2,0,-2 // left
DrawRect 1,-2,2,2 // right
DrawRect 0,0,1,-2 // top
DrawRect -2,1,2,2 // bottom
SetDrawEnv pop
End
Macro ClearrPlotAreaMask(layerName)
String layerName="UserBack"
Prompt layerName, "Clear Mask on layer", popup, "ProgBack;UserBack;ProgAxes;UserAxes;ProgFront;UserFont;"
SetDrawLayer/K $layerName
End
The default is UserBack with the expectation that drawing is done on the ProgBack layer; masking on this level prevents covering up the axes.
Since you can move the axes above the traces, you might draw axes on top of traces:
ModifyGraph axisOnTop=1
You might draw on the ProgAxes layer and put the mask on the UserAxes layer.
--Jim Prouty
Software Engineer, WaveMetrics, Inc.
June 7, 2017 at 05:55 pm - Permalink
After drawing on the ProgBack layer, I added the following code:
SetDrawEnv push
SetDrawEnv xcoord=prel, ycoord=prel, linethick=0, fillfgc=(65535,65535,65535), save
DrawRect -2,2,0,-2 // left
DrawRect 1,-2,2,2 // right
DrawRect 0,0,1,-2 // top
DrawRect -2,1,2,2 // bottom
SetDrawEnv pop
This allows me to resize and zoom at will while displaying the drawn objects only within the plot rectangle.
Thanks again!
June 9, 2017 at 01:04 pm - Permalink