Setting resolution of a non-eps plot (jpg, png)

37 views
Skip to first unread message

tracey....@gmail.com

unread,
Jul 22, 2013, 5:34:24 PM7/22/13
to plotinum...@googlegroups.com
I would like to make a "high-resolution" plot, and I'm confused on how to do so. Are jpgs and pngs a fixed number of pixels per inch? Is there a way to modify that?

Thanks

tracey....@gmail.com

unread,
Jul 22, 2013, 6:01:36 PM7/22/13
to plotinum...@googlegroups.com, tracey....@gmail.com
Oh, I think I understand how this works now. The resolution is purely set in the plotinum/vg package. It looks like, for example, that GlyphStyle.Radius is specified then by number of pixels, and not, say, a percentage of the overall length of the plot. Does it have to be this way? (Too late to fix now, but thinking about the gonum port)

Dan Kortschak

unread,
Jul 22, 2013, 6:10:22 PM7/22/13
to tracey....@gmail.com, plotinum...@googlegroups.com
There was a thread on golang-nuts about the handling of png size
metadata a short while ago; from memory the png writer does not specify
the physical size of the png, but check that (Nigel Tao answered that).
I imagine jpeg is similar.

Dan Kortschak

unread,
Jul 22, 2013, 6:12:03 PM7/22/13
to tracey....@gmail.com, plotinum...@googlegroups.com
Just calculate the absolute size from the plot size and desired relative
size. This is not very nice depending on how precise you want to be
(i.e. relative to the canvas size or the plot area - latter is harder).

Dan

tracey....@gmail.com

unread,
Jul 22, 2013, 8:52:16 PM7/22/13
to plotinum...@googlegroups.com, tracey....@gmail.com
For my future reference, here's what it seems to take to scale the axis if you use a different size than 4 inches by 4 inches

mult := 2.0
multvg := vg.Length(mult)
initLineWidth := plt.X.LineStyle.Width
initFontSize := plt.X.Label.Font.Size
initTickFontSize := plt.X.Tick.Label.Font.Size
initTickLength := plt.X.Tick.Width
plt.X.Label.Font.Size = multvg * initFontSize
plt.Y.Label.Font.Size = multvg * initFontSize
plt.X.Tick.Label.Font.Size = multvg * initTickFontSize
plt.Y.Tick.Label.Font.Size = multvg * initTickFontSize
plt.X.Tick.Width = multvg * initTickLength
plt.Y.Tick.Width = multvg * initTickLength
plt.X.LineStyle.Width = multvg * initLineWidth
plt.Y.LineStyle.Width = multvg * initLineWidth
err = plt.Save(6*mult, 4*mult, plotNameJPG)

Reply all
Reply to author
Forward
0 new messages