Adding Greek Characters To Plots

Ben Abbott bpabbott at mac.com
Thu Oct 16 06:54:40 CDT 2008


On Oct 16, 2008, at 4:42 AM, David Bateman wrote:

> Ben Abbott wrote:
>>
>> David, thanks for letting me handle this change. I've learned a  
>> bit ... in particular, I learned how simple it was to make the  
>> change ;-)
>>
>> The change to __go_draw_axes__.m defaults to "tex" if there is not  
>> axes property for "interpreter". That way you can see it at work.  
>> Once the axes have an interpreter property the if-block in  
>> __go_draw_axes__ (do_tics) may be deleted ... or left as it is.
>>
>> A simple example of its use is below
>>
>> x = pi * (0:10)/10;
>> xtick = [0:0.25:1.01]*pi;
>> xticklabel = {'0', '\pi/4', '\pi/2', '3\pi/4', '\pi'};
>> figure(1)
>> clf
>> axes();
>> plot (x,sin(x))
>> set (gca, "xtick", xtick, "xticklabel", xticklabel)
>> xlim ([0, pi])
>>
>> If a subsequent newplot is made to the axis the ticklabels are  
>> reset to their default values (as is done in Matlab). I suggest the  
>> interpreter value do the same (which it would unless newplot() is  
>> modified).
>
> This is not quite right as the test
>
> +  if (~isfield (obj, 'interpreter'))
> +    obj.interpreter = 'tex';
> +  endif
>
> in do_tics shouldn't be there and graphics.h.in should have the  
> attached change made to it. Note that at the suggestion of John, the  
> default behavior of the of the interpreter property of the axes is  
> set to none for compatibility. I attached an updated changeset  
> credited to you.
>
> The example to get what you want would then be
>
> x = pi * (0:10)/10;
> xtick = [0:0.25:1.01]*pi;
> xticklabel = {'0', '\pi/4', '\pi/2', '3\pi/4', '\pi'};
> figure(1)
> clf
> axes();
> plot (x,sin(x))
> set (gca, "xtick", xtick, "xticklabel", xticklabel, "interpreter",  
> "tex")
> xlim ([0, pi])
>
> Regards
> David

(snip)

> 	* ov-class.c (Fsuperiorto, Finferiorto): Allow more than one class
> diff --git a/src/graphics.h.in b/src/graphics.h.in
> --- a/src/graphics.h.in
> +++ b/src/graphics.h.in
> @@ -2585,6 +2585,7 @@
>       radio_property xticklabelmode , "{auto}|manual"
>       radio_property yticklabelmode , "{auto}|manual"
>       radio_property zticklabelmode , "{auto}|manual"
> +      radio_property interpreter , "tex|{none}|latex"
>       color_property color , color_property (color_values (1, 1, 1),  
> radio_values ("none"))
>       color_property xcolor , color_values (0, 0, 0)
>       color_property ycolor , color_values (0, 0, 0)

Very nice. I'd never looked into graphic.h.in.

Thanks
Ben


More information about the Help-octave mailing list