Contents
Hollow markers
When datapoints in type marker scatterplots comes too close together, it is difficult to judge how many of them are in close vicinity. Markers being circular and hollow helps.
NB. ==== plot hack: hollow markers instead of full markers
isimarker_jzplot_=: 3 : 0
's m f e c p'=. y
p=. gpflip p
NB. HERE WAS: gpbuf gppenbrush1 e
gpbuf 5 2032,(,e),4 2022 1 0 2 2005
s ('isimark_',m)~ p
)-- 2010-07-16 18:34:38
Save bitmap
The following command saves currently open plot window as a bitmap of exctly same size as it is on the screen.
pd 'save bmp z.bmp ',":_2{.Pxywh_jwplot_-- 2010-07-16 18:34:38
Coordinates
This handler prints x and y coordinates of a point in plot axis units upon doubleclick on plot area.
plot_gs_mbldbl_jwplot_=:3 : 0
xy=.2{.".sysdata
if. *./(xy>:2{.Gxywh),(xy<: 2 ({. + }.)Gxywh) do.
px=.XMin +(XMax-XMin)*(2{Gxywh)%~({.xy)-(0{Gxywh)
py=.YMin +(YMax-YMin)*(3{Gxywh)%~((3{Pxywh)-{:xy)-(1{Gxywh)
smoutput 'x,y=',":px,py
end.
)-- 2010-07-16 20:04:42
Copy working plot
NB. may need P0=:conew 'jzplot' do__P0 'pd ''show'' [ PCmd=:PCmd_jwplot_ [ pd ''reset'''
Copy plot data from working plot jwplot into named (P0) and redisplay it
-- 2010-07-29 17:08:14
Save plot as .ijs script
NB.*psj v save currently open plot as ijs script
psj=:3 : 0
f=.'require ''plot''',CRLF
f=.f,'pd ''reset''',CRLF
f=.f,'PCmd_jwplot_=:'
e=.CRLF,'pd ''show''',CRLF
e=.e,'wd ''pmovex '',":',(":wd 'qformx'),CRLF
(f , (5!:5 <'PCmd_jwplot_') , e) 1!:2 boxopen y
i.0 0
)Saves plot settigns, data and window position and location in J script file. When this file is run, it reproduces original plot.
-- 2010-07-29 18:09:29
Custom color scheme -- MAP
MAPCLR_jzplot_=: 64 colorxy_jzplot_ 0 0 0.3, 0 1 1,1 1 0,0.8 0.2 0,i.0 0 k=.(,|.) (1+i.5) 'bandcolor mapclr;type density' plot (1 1,:2##k) (k +/ . * ] +/ . * k"_);._3 ?100 100$0
Specify set of colors for density (and contour) plots. Example shows bandcolor that resembles geographic maps, with deep blue depths, cyan shallows, green lowlands and yellow to orange to brown highlands.
-- 2010-08-03 20:09:31
Scroll plot horizontally
See plotscroll
-- 2010-08-04 17:22:11
Force X axis units equal to Y axis units
Command
'type poly' plot 0 1j5+/^ 0j2p1 * (%~ i.) 5
displays 2 offset regular pentagons. Pentagons may not look regular depending on the proportions of the plot window. The following command forces X axis untis to become Y axis units on the already displayed plot, so that in our case pentagons will look regular.
pd 'aspect ',(":do_jwplot_ '(YMax-YMin)%(XMax-XMin)'),';show'-- 2010-08-12 20:16:09
Tweak viewpoint in 3D plot
plot3dview shows how to do that. Requiers adjuster
-- 2010-08-20 21:04:58
Clone plot in a new window
NB.*pclone v creates a clone of plot y, '' defaults to 'jwplot' pclone_jzplot_=:3 : 0 if. a:-:y=.boxopen y do. y=.<'jwplot' end. PCmd=:PCmd__y pd 'show' )
This is a way to "freeze" plot that had been interactively constructed by issuing pd commands. Call as pclone__P0 '', assuming P0=:conew 'jzplot' has been done previously.
-- 2011-05-12 14:04:12
Use ''minus'' instead of ''hyphen'' for negative labels
Mathematical minus sign (−) is different from hyphen (-), which is actually used by plot to format negative numbers. Minus is wider and is located a little bit higher (on the same level as horizontal part of +). Most of the time it does not matter, when it does the following hack to the label formatting verb fixes it.
lfmt_jzplot_=:3 : 0 dat=. ": y txt=. ,dat utf8 (u:8722) (I. txt='_') } txt )
-- 2011-05-13 21:09:04
pclose fix
When jwplot is mixed with instances of other jzplots, sometimes an attempt to close it (jwplot) causes one of the other instances of jzplot to close.
This is the fix.
pclose_jzplot_=:3 : 0
if. ifjwplot'' do.
NB. this still might select wrong window and save position of one of jzplots
wpsave_j_ :: 0: PForm
end.
wd 'psel ',PFormhwnd
wd 'pclose'
pd 'reset'
)-- 2011-05-17 14:54:46
