|
From: Daniel J S. <dan...@ie...> - 2012-10-11 23:38:52
|
On 10/11/2012 06:31 PM, Ethan A Merritt wrote: > On Thursday, October 11, 2012 04:13:55 pm Ethan A Merritt wrote: >> On Thursday, October 11, 2012 12:42:22 pm Allin Cottrell wrote: >>> I'm comparing the output of gnuplot's svg and pngcairo >>> drivers, with a thought of making greater use of SVG. But >>> there seems to be a slight problem with the placement of key >>> text in the SVG output. Here's a little test script >>> >>> set term svg font "Sans,8" size 680,400 >>> set output 'test.svg' >>> set key left top >>> plot sin(x) title "PRIME" w l, \ >>> cos(x) title "UNEMP" w l >>> set term pngcairo font "Sans,8" size 680,400 >>> set output 'test.png' >>> replot >>> >>> In the PNG version the key is just fine, but in SVG the "U" of >>> "UNEMP" gets tangled up with the y-axis (more or less, >>> depending on the magnification). >> >> The underlying issue is that for SVG, like PostScript, gnuplot has >> to guess at the font properties for a font that will not actually >> be selected until the file is later viewed in another program. > > By the way, if you turn on the "box" attribute of the key you can > see that the key box itself is properly placed. The problem is that in > your case the width of the box is too small because the size of the text > was underestimated. > > As a work-around, you could use "set key left Left". > That anchors the left end of the text rather than the right end, > so it is not at risk of overwriting the left plot border. > Instead the right end of the text might run into the line sample ;-) One might be able to put a space at the front or end of the text to compensate for that as well. (And there might even be some parameters associated with key text that can be adjusted.) The easiest alternative is probably to look for a font that both gnuplot can use for width information and that the SVG driver can use for display. Dan > > Ethan > > > > >> Here is the relevant code snippet from svg.trm: >> >> /* since we cannot interrogate SVG about text properties and according >> * to SVG 1.0 W3C Candidate Recommendation 2 August 2000 the >> * "line-height" of the 'text' element is defined to be equal to the >> * 'font-size' (!), we have to to define font properties in a less >> * than optimal way */ >> SVG_fontAscent = (int) (SVG_fontSizeCur * 1.00 * SVG_SCALE); >> SVG_fontDescent = (int) (SVG_fontSizeCur * 0.25 * SVG_SCALE); >> SVG_fontLeading = (int) (SVG_fontSizeCur * 0.25 * SVG_SCALE); >> SVG_fontAvWidth = (int) (SVG_fontSizeCur * 0.70 * SVG_SCALE); >> >> Apparently for the font your viewer is choosing in response to a >> request for "Sans", the average character width is greater than >> 70% of the nominal font size. It would be easy enough to bump >> SVG_fontAvWidth up to 0.8 or something, but I imagine that in >> turn might be too wide for other viewer+font+text combinations. >> >> Contributing to the problem in your particular example is that fact that >> the title is in all caps, and capital letters are wider than the "average" >> letter in most proportionally-spaced fonts. We might be able to address >> this part of the problem by modifying gnuplot's string width estimator >> to bump up the estimate if there are many capital letters in the string. >> >> Ethan >> >> >> >> >> >>> I'm looking at the SVG using >>> librsvg, and also via the Adobe NPSVG3 library. To show what >>> I'm talking about, I'm attaching the SVG output as converted >>> to PNG by rsvg-convert (at 96dpi). >>> >>> >> >> >> ------------------------------------------------------------------------------ >> Don't let slow site performance ruin your business. Deploy New Relic APM >> Deploy New Relic app performance management and know exactly >> what is happening inside your Ruby, Python, PHP, Java, and .NET app >> Try New Relic at no cost today and get our sweet Data Nerd shirt too! >> http://p.sf.net/sfu/newrelic-dev2dev >> _______________________________________________ >> gnuplot-beta mailing list >> gnu...@li... >> https://lists.sourceforge.net/lists/listinfo/gnuplot-beta >> > > > ------------------------------------------------------------------------------ > Don't let slow site performance ruin your business. Deploy New Relic APM > Deploy New Relic app performance management and know exactly > what is happening inside your Ruby, Python, PHP, Java, and .NET app > Try New Relic at no cost today and get our sweet Data Nerd shirt too! > http://p.sf.net/sfu/newrelic-dev2dev > _______________________________________________ > gnuplot-beta mailing list > gnu...@li... > https://lists.sourceforge.net/lists/listinfo/gnuplot-beta > -- Dan Sebald email: daniel(DOT)sebald(AT)ieee(DOT)org URL: http://www(DOT)dansebald(DOT)com |