Share your ideas for the JMP Scripting Unsession at Discovery Summit by September 17th. We hope to see you there!
Choose Language Hide Translation Bar
Highlighted
Ingerid
Level II

Output picture size in pixels

Hi!

I have a large series of plots that I need to output as png, emf and svg, and they have to be exactly 500x300 pixels. This has proven incredibly difficult to achieve. I know that I can specify the size of the graph builder using Size(), but that results in a plot that is significantly larger due to added axis titles, plot title, legends, margins and such.

To explain what I'm doing: I add an OnOpen script to my datatable which plots my data using the Graph builder, and create a report and use that to add axis titles and such. I have another script that opens the data table and extracts the picturebox from the generated report. This is then put into a VListBox together with plot titles and such. This box is then exported using SavePicture().

vlb = VListBox(
	Align(center),
	tb1 = TextBox(
		"",
		SetFontSize(numFONTSIZETITLE),
		SetFontStyle(strFONTSTYLETITLE),
		SetFont(strFONTITLE),
		SetWrap(0.9*numLENGTHEXPORT)),
	tb2 = TextBox(
		"Title",
		SetFontSize(numFONTSIZETITLE),
		SetFontStyle(strFONTSTYLETITLE),
		SetFont(strFONTITLE),
		SetWrap(0.9*numLENGTHEXPORT)),
	tb3 = TextBox(
		strComments,
		SetFontSize(numFONTSIZECOMMENTS),
	        SetFontStyle(strFONTSTYLECOMMENTS),
		SetFont(strFONTCOMMENTS),
		SetWrap(0.9*numLENGTHEXPORT)),
	pb1 = reportgraphbuilder[PictureBox(1)]
);
vlb << Save Picture(drFolderSave || strPlotName || ".emf", emf);
vlb << Save Picture(drFolderSave || strPlotName || ".png", png);
vlb << Save Picture(drFolderSave || strPlotName || ".svg", svg);

I tried to change the size of the VListBox, but the VListBox insists that it has a size of {0,0}, which makes no sense since it contains a quite large picturebox. I tried to generate a FrameBox around it, but I only get error messages. I've looked for more documentation on that box, but I can only find documentation on the functions you can send to it, not how to generate one or when you should use it.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Thierry_S
Level VI

Re: Output picture size in pixels

Hi,
Have you tried to first capture the plots as an image (MyPict = vlb << Get Picture ()) and then use the MyPict << Set Size ({500, 300})?
Thierry R. Sornasse

View solution in original post

2 REPLIES 2
Highlighted
Thierry_S
Level VI

Re: Output picture size in pixels

Hi,
Have you tried to first capture the plots as an image (MyPict = vlb << Get Picture ()) and then use the MyPict << Set Size ({500, 300})?
Thierry R. Sornasse

View solution in original post

Highlighted
Ingerid
Level II

Re: Output picture size in pixels

Wow, that worked! Thank you so much!
Article Labels

    There are no labels assigned to this post.