[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Adding Greek Characters To Plots
From: |
David Bateman |
Subject: |
Re: Adding Greek Characters To Plots |
Date: |
Thu, 16 Oct 2008 09:42:26 +0100 |
User-agent: |
Mozilla-Thunderbird 2.0.0.16 (X11/20080724) |
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
--
David Bateman address@hidden
Motorola Labs - Paris +33 1 69 35 48 04 (Ph)
Parc Les Algorithmes, Commune de St Aubin +33 6 72 01 06 33 (Mob)
91193 Gif-Sur-Yvette FRANCE +33 1 69 35 77 01 (Fax)
The information contained in this communication has been classified as:
[x] General Business Information
[ ] Motorola Internal Use Only
[ ] Motorola Confidential Proprietary
# HG changeset patch
# User Ben Abbott <address@hidden>
# Date 1224146456 -3600
# Node ID 920dc2ae50b2b59b73d34d903085f4a934125b4e
# Parent 7ca9fc4575ee2911419619db1b7d895dfb4eb281
Support axes interpreter poperty for tick labels
diff --git a/scripts/ChangeLog b/scripts/ChangeLog
--- a/scripts/ChangeLog
+++ b/scripts/ChangeLog
@@ -1,3 +1,7 @@
+2008-10-15 Ben Abbott <address@hidden>
+
+ * plot/__go_draw_axes__.m: Support axes interpreter poperty for tick
labels.
+
2008-10-15 David Bateman <address@hidden>
* general/colon.m: Small typo.
diff --git a/scripts/plot/__go_draw_axes__.m b/scripts/plot/__go_draw_axes__.m
--- a/scripts/plot/__go_draw_axes__.m
+++ b/scripts/plot/__go_draw_axes__.m
@@ -1364,55 +1364,66 @@
if (strcmpi (obj.xaxislocation, "top"))
do_tics_1 (obj.xtickmode, obj.xtick, obj.xticklabelmode, obj.xticklabel,
obj.xcolor, "x2", plot_stream, true, mono, "border",
- obj.tickdir, fontname, fontsize);
+ obj.tickdir, fontname, fontsize, obj.interpreter);
do_tics_1 ("manual", [], obj.xticklabelmode, obj.xticklabel,
obj.xcolor, "x", plot_stream, true, mono, "border",
- "", fontname, fontsize);
+ "", fontname, fontsize, obj.interpreter);
elseif (strcmpi (obj.xaxislocation, "zero"))
do_tics_1 (obj.xtickmode, obj.xtick, obj.xticklabelmode, obj.xticklabel,
obj.xcolor, "x", plot_stream, true, mono, "axis",
- obj.tickdir, fontname, fontsize);
+ obj.tickdir, fontname, fontsize, obj.interpreter);
do_tics_1 ("manual", [], obj.xticklabelmode, obj.xticklabel,
obj.xcolor, "x2", plot_stream, true, mono, "axis",
- "", fontname, fontsize);
+ "", fontname, fontsize, obj.interpreter);
else
do_tics_1 (obj.xtickmode, obj.xtick, obj.xticklabelmode, obj.xticklabel,
obj.xcolor, "x", plot_stream, true, mono, "border",
- obj.tickdir, fontname, fontsize);
+ obj.tickdir, fontname, fontsize, obj.interpreter);
do_tics_1 ("manual", [], obj.xticklabelmode, obj.xticklabel,
obj.xcolor, "x2", plot_stream, true, mono, "border",
- "", fontname, fontsize);
+ "", fontname, fontsize, obj.interpreter);
endif
if (strcmpi (obj.yaxislocation, "right"))
do_tics_1 (obj.ytickmode, obj.ytick, obj.yticklabelmode, obj.yticklabel,
obj.ycolor, "y2", plot_stream, ymirror, mono, "border",
- obj.tickdir, fontname, fontsize);
+ obj.tickdir, fontname, fontsize, obj.interpreter);
do_tics_1 ("manual", [], obj.yticklabelmode, obj.yticklabel,
obj.ycolor, "y", plot_stream, ymirror, mono, "border",
- "", fontname, fontsize);
+ "", fontname, fontsize, obj.interpreter);
elseif (strcmpi (obj.xaxislocation, "zero"))
do_tics_1 (obj.ytickmode, obj.ytick, obj.yticklabelmode, obj.yticklabel,
obj.ycolor, "y", plot_stream, ymirror, mono, "axis",
- obj.tickdir, fontname, fontsize);
+ obj.tickdir, fontname, fontsize, obj.interpreter);
do_tics_1 ("manual", [], obj.yticklabelmode, obj.yticklabel,
obj.ycolor, "y2", plot_stream, ymirror, mono, "axis",
- "", fontname, fontsize);
+ "", fontname, fontsize, obj.interpreter);
else
do_tics_1 (obj.ytickmode, obj.ytick, obj.yticklabelmode, obj.yticklabel,
obj.ycolor, "y", plot_stream, ymirror, mono, "border",
- obj.tickdir, fontname, fontsize);
+ obj.tickdir, fontname, fontsize, obj.interpreter);
do_tics_1 ("manual", [], obj.yticklabelmode, obj.yticklabel,
obj.ycolor, "y2", plot_stream, ymirror, mono, "border",
- "", fontname, fontsize);
+ "", fontname, fontsize, obj.interpreter);
endif
do_tics_1 (obj.ztickmode, obj.ztick, obj.zticklabelmode, obj.zticklabel,
obj.zcolor, "z", plot_stream, true, mono, "border",
- obj.tickdir, fontname, fontsize);
+ obj.tickdir, fontname, fontsize, obj.interpreter);
endfunction
function do_tics_1 (ticmode, tics, labelmode, labels, color, ax,
plot_stream, mirror, mono, axispos, tickdir,
- fontname, fontsize)
+ fontname, fontsize, interpreter)
+ persistent warned_latex = false;
+ if (strcmpi (interpreter, "tex"))
+ for n = 1 : numel(labels)
+ labels{n} = __tex2enhanced__ (labels{n}, fontname, false, false);
+ endfor
+ elseif (strcmpi (interpreter, "latex"))
+ if (! warned_latex)
+ warning ("latex text objects not supported");
+ warned_latex = true;
+ endif
+ endif
if (strcmp (fontname, "*"))
fontspec = "";
else
diff --git a/src/ChangeLog b/src/ChangeLog
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,7 @@
+2008-10-15 David Bateman <address@hidden>
+
+ * graphics.h.in (axes::properties::interpreter): New property.
+
2008-10-15 David Bateman <address@hidden>
* 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)
- Re: Adding Greek Characters To Plots, (continued)