Default font for gnuplot in Octave plotting
Ben Abbott
bpabbott at mac.com
Sun May 24 14:41:16 CDT 2009
On May 24, 2009, at 12:46 PM, rdrider0-list at yahoo.com wrote:
> Ben Abbott wrote:
>>
>> On May 24, 2009, at 12:39 AM, rdrider0-list at yahoo.com wrote:
>>
>>> 5/23/09
>>>
>>> Ben,
>>>
>>> I'm coming across some odd behavior with plotting since the
>>> removal of
>>> the file __gnuplot_default_font__.m.
>>>
>>> The following sequence works.
>>> plot(rand(50,1));
>>> title("hello world");
>>>
>>> When you add a label that uses the TeX interpreter such as
>>> xlabel('\pi + 1');
>>>
>>> the title switches into a Greek font. Switching the label back to
>>> something normal without markup, xlabel('junk'),
>>> causes the title to revert to "hello world".
>>>
>>> Overriding the default fontname of "*" on the title does correct the
>>> situation but to my mind it would be preferable
>>> if the item with markup, in my example it was xlabel, had its
>>> default
>>> font changed to Greek or Symbol but left the
>>> other items alone.
>>>
>>> Thoughts?
>>>
>>> Rik
>>
>>
>> I recall being able to reproduce a similar example a few weeks ago,
>> but am not able to do so now. Meaning my title does not change to the
>> Greek/Symbol font.
>>
>> My tip is
>>
>> changeset: 9247:b2790fd23800
>> tag: tip
>> user: Michael Goffioul <michael.goffioul at gmail.com>
>> date: Fri May 22 23:48:04 2009 +0100
>> summary: More export symbols to allow usage from an IDE.
>>
>> The last changeset that appears to have touched on this part of the
>> code is 6 weeks old.
>>
>> http://hg.savannah.gnu.org/hgweb/octave/rev/5ecdb3d3568f
>>
>> I noticed you've applied a changeset as recent as 2 days ago, so I
>> assume you are up to date?
>>
>> Personally, I'm confused as to why I'm unable to reproduce what
>> you're
>> seeing. I tried both gnuplot 4.3 and 4.2.5. What version of gnuplot
>> are you running?
> I did a full purge and rebuild from the latest Mercurial Tip and the
> problem is still there for me. I'm using gnuplot 4.2.2 which is the
> default for the Long Term Release of Ubuntu Hardy Heron.
>
> --Rik
Ok, I do see the problem in gnuplot 4.2.2-4, but only for the x11
terminal. The problem is absent in gnuplot 4.2.5 and 4.3.0.
I have an idea for a simple fix. The following snippet in
__go_draw_axes__.m can be changed when the terminal is x11 and the
gnuplot version < 4.2.5 (__gnuplot_has_feature__ can be added to
detect this).
1326 function fontspec = create_fontspec (f, s)
1327 if (strcmp (f, "*"))
1328 fontspec = sprintf ("font \",%d\"", s);
1329 else
1330 fontspec = sprintf ("font \"%s,%d\"", f, s);
1331 endif
1332 endfunction
For the case in question the fontspec can be changed to use the "*"
1326 function fontspec = create_fontspec (f, s)
1327 if (strcmp (f, "*") &&
__gnuplot_has_feature__("anonymous_font_supports_symbols"))
1328 fontspec = sprintf ("font \",%d\"", s);
1329 else
1330 fontspec = sprintf ("font \"%s,%d\"", f, s);
1331 endif
1332 endfunction
I have limited time to work on this at the moment, so it may be a week
or so before I have the opportunity.
For a temporary solution; I suggest (1) updating to gnuplot 4.2.5, (2)
changing your terminal type, or (3) specifying a default fontname
which your system supports.
For (3), you can add the following to your ~/.octaverc
set (0, "defaultaxesfontname", "Arial")
set (0, "defaulttextfontname", "Arial")
In my case, there is no specific fonts which work across all
terminals, so (3) will fix the x11 problem, but may reveal another.
Ben
More information about the Octave-maintainers
mailing list