Discussion:
superscript, subscript, Greek characters in plot labels?
Ron Crummett
2005-10-27 00:31:45 UTC
Permalink
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Hi - <br>
<br>
Is it possible to get nicely-formatted titles and labels for plots like
in MATLAB?&nbsp; If I want a title to read "y = x<sup>2</sup>" I can type in
"title('y = x^2')" and it will output it as described before, or if I
want a Greek character, say <font face="Symbol">w<font
face="Times New Roman">, I can type "\omega" like in LaTeX</font></font>.&nbsp;
Is there some way to do this in Octave?&nbsp; If so, how?&nbsp; Thanks.<br>
<br>
-Ron Crummett<br>
</body>
</html>



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------
John W. Eaton
2005-10-27 00:49:18 UTC
Permalink
On 26-Oct-2005, Ron Crummett wrote:

| Is it possible to get nicely-formatted titles and labels for plots like
| in MATLAB?&nbsp; If I want a title to read "y = x<sup>2</sup>" I can type in
| "title('y = x^2')" and it will output it as described before, or if I
| want a Greek character, say <font face="Symbol">w<font
| face="Times New Roman">, I can type "\omega" like in LaTeX</font></font>.&nbsp;
| Is there some way to do this in Octave?&nbsp; If so, how?&nbsp; Thanks.<br>

Yes. You can use gnuplot's epslatex (or pslatex) terminal (works best
if you are using the figures in a LaTeX document). Or you can use the
enhanced option for the PostScript terminal.

For help, start gnuplot (at the shell prompt, outside of Octave) and
type

help set term epslatex

or

help set term postscript enhanced

jwe



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------
Henry F. Mollet
2005-10-27 01:45:06 UTC
Permalink
Loading Image...
Not sure about subscripts and superscripts but Greek characters should work
in labels. Should work in titles also but I have not tried.

I was looking for the code but cannot find it and cannot remember because
it's not menu driven. I'll be searching because I want to know also how I
did it.
Henry
Hi -
Is it possible to get nicely-formatted titles and labels for plots like in
MATLAB? If I want a title to read "y = x2" I can type in "title('y = x^2')"
and it will output it as described before, or if I want a Greek character, say
w, I can type "\omega" like in LaTeX. Is there some way to do this in Octave?
If so, how? Thanks.
-Ron Crummett
------------------------------------------------------------- Octave is freely
http://www.octave.org/archive.html
-------------------------------------------------------------
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------
A S Hodel
2005-10-27 13:21:17 UTC
Permalink
Post by Ron Crummett
Hi -
Is it possible to get nicely-formatted titles and labels for plots
like in MATLAB?  If I want a title to read "y = x2" I can type in
"title('y = x^2')" and it will output it as described before, or if I
want a Greek character, say w, I can type "\omega" like in LaTeX.  Is
there some way to do this in Octave?  If so, how?  Thanks.
-Ron Crummett
-------------------------------------------------------------
I had a similar question last spring. The best answer of the many
provided involves the use of the script fig2ps and a slight
modification to the octave-forge print.m function so that it generates
fig files with "special" text. You also need to pay attention to the
fact that the backslash character "\" is escaped a couple of times in
the octave scripts, so you need to write
\\\\omega
instead of
\omega
in the octave plot command legend, or, if you use the octave-forge
legend command,
I think you need eight backslashes instead of four. Weird and
annoying, but you get what you want in the output.

Details and an example are on my AU weblog,
http://www.eng.auburn.edu/users/hodelas/classes/C294999662/
E20051027080644/index.html

A Scottedward Hodel, PhD, Associate Professor
Dept. Electrical and Computer Engineering, 200 Broun Hall
Auburn University, AL 36849-5201
(334) 844-1854 Fax: (34) 844-1809
http://www.eng.auburn.edu/~hodelas
Quentin Spencer
2005-10-27 14:51:59 UTC
Permalink
I had a similar question last spring. The best answer of the many
provided involves the use of the script fig2ps and a slight
modification to the octave-forge print.m function so that it generates
fig files with "special" text.
I also use fig2ps and recommend it.
You also need to pay attention to the fact that the backslash
character "\" is escaped a couple of times in the octave scripts, so
you need to write
\\\\omega
instead of
\omega
in the octave plot command legend, or, if you use the octave-forge
legend command,
I think you need eight backslashes instead of four. Weird and
annoying, but you get what you want in the output.
Another way to deal with this problem is using the undo_string_escapes
function:
octave:1> undo_string_escapes('\a')
ans = \\a
octave:2> undo_string_escapes('\\a')
ans = \\\\a

I've also noticed the need for a potentially large number of backslashes
when using certain commands like legend. Ideally, those functions should
be calling undo_string_escapes internally each time they evaluate the
strings so that the number of backslahes you need is always consistent.
Are the legend commands the only ones you've found with this problem?

-Quentin



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------
John W. Eaton
2005-10-27 15:00:56 UTC
Permalink
On 27-Oct-2005, Quentin Spencer wrote:

| Another way to deal with this problem is using the undo_string_escapes
| function:
| octave:1> undo_string_escapes('\a')
| ans = \\a
| octave:2> undo_string_escapes('\\a')
| ans = \\\\a
|
| I've also noticed the need for a potentially large number of backslashes
| when using certain commands like legend. Ideally, those functions should
| be calling undo_string_escapes internally each time they evaluate the
| strings so that the number of backslahes you need is always consistent.
| Are the legend commands the only ones you've found with this problem?

And this will all unfortunately change with 2.9.x and later versions,
which do nothing special for backslash in single-quoted strings (for
compatibility) but do expand backslash escapes in the usual way when
they appear in double-quoted strings.

But, you still have the problem that external programs may interpret
the backslashes, so even if Octave passes them along unmolested to
some output file, a program like fig2ps may need to have them doubled
up.

jwe



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------
Jonathan Stickel
2005-10-27 15:16:58 UTC
Permalink
Post by A S Hodel
The best answer of the many
provided involves the use of the script fig2ps and a slight modification
to the octave-forge print.m function so that it generates fig files with
"special" text.
fig2ps takes an option "--forcespecial" so that the text need not be
"special" in the .fig file itself.

Another thing not yet mentioned is the use of sans serif fonts. I
accomplish this with a "sans_fonts.sty" file which contains the two lines

\renewcommand{\familydefault}{\sfdefault}
\usepackage{sfmath}

where sfmath.sty I downloaded from

http://dtrx.de/od/tex/sfmath.html

Then call fig2ps like this:

fig2ps --add=type1cm,sans_fonts figure.fig

The package "type1cm" causes latex to use scalable fonts.

HTH,
Jonathan



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------
John W. Eaton
2005-10-27 15:24:41 UTC
Permalink
On 27-Oct-2005, Jonathan Stickel wrote:

| A S Hodel wrote:
| > The best answer of the many
| > provided involves the use of the script fig2ps and a slight modification
| > to the octave-forge print.m function so that it generates fig files with
| > "special" text.
|
| fig2ps takes an option "--forcespecial" so that the text need not be
| "special" in the .fig file itself.
|
| Another thing not yet mentioned is the use of sans serif fonts. I
| accomplish this with a "sans_fonts.sty" file which contains the two lines
|
| \renewcommand{\familydefault}{\sfdefault}
| \usepackage{sfmath}
|
| where sfmath.sty I downloaded from
|
| http://dtrx.de/od/tex/sfmath.html
|
| Then call fig2ps like this:
|
| fig2ps --add=type1cm,sans_fonts figure.fig
|
| The package "type1cm" causes latex to use scalable fonts.

If you are using LaTeX, then why go through the extra fig file format?
Why not use the epslatex terminal?

jwe



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------
Jonathan Stickel
2005-10-27 15:48:49 UTC
Permalink
Post by John W. Eaton
| > The best answer of the many
| > provided involves the use of the script fig2ps and a slight modification
| > to the octave-forge print.m function so that it generates fig files with
| > "special" text.
|
| fig2ps takes an option "--forcespecial" so that the text need not be
| "special" in the .fig file itself.
|
| Another thing not yet mentioned is the use of sans serif fonts. I
| accomplish this with a "sans_fonts.sty" file which contains the two lines
|
| \renewcommand{\familydefault}{\sfdefault}
| \usepackage{sfmath}
|
| where sfmath.sty I downloaded from
|
| http://dtrx.de/od/tex/sfmath.html
|
|
| fig2ps --add=type1cm,sans_fonts figure.fig
|
| The package "type1cm" causes latex to use scalable fonts.
If you are using LaTeX, then why go through the extra fig file format?
Why not use the epslatex terminal?
jwe
We've had this conversation before :)

http://www.octave.org/mailing-lists/help-octave/2005/166

It is a matter of personal preference. I much prefer having standalone,
printable pdf figures. (I actually use 'fig2pdf' rather than 'fig2ps.)
These I include in latex documents with "\includegraphics{}" rather
than "\input{}". Another advantage is that these figures are easy to
submit when submitting documents to journals.

Jonathan



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------
Quentin Spencer
2005-10-27 16:32:23 UTC
Permalink
Post by Jonathan Stickel
| > The best answer of the many | > provided involves the use of the
script fig2ps and a slight modification | > to the octave-forge
print.m function so that it generates fig files with | > "special"
text. | | fig2ps takes an option "--forcespecial" so that the text
need not be | "special" in the .fig file itself.
| | Another thing not yet mentioned is the use of sans serif fonts.
I | accomplish this with a "sans_fonts.sty" file which contains the
two lines
| | \renewcommand{\familydefault}{\sfdefault}
| \usepackage{sfmath}
| | where sfmath.sty I downloaded from
| | http://dtrx.de/od/tex/sfmath.html
| | fig2ps --add=type1cm,sans_fonts figure.fig
| | The package "type1cm" causes latex to use scalable fonts.
If you are using LaTeX, then why go through the extra fig file format?
Why not use the epslatex terminal?
jwe
We've had this conversation before :)
http://www.octave.org/mailing-lists/help-octave/2005/166
It is a matter of personal preference. I much prefer having
standalone, printable pdf figures. (I actually use 'fig2pdf' rather
than 'fig2ps.) These I include in latex documents with
"\includegraphics{}" rather than "\input{}". Another advantage is
that these figures are easy to submit when submitting documents to
journals.
When I discovered fig2ps (thanks to Jonathan, I believe), I also moved
away from using \input to using \includegraphics for the same reason.
The old way worked fine for my makefile-based way of creating latex
documents, but publishers always want self-contained figures that are
separate from the text of the document. The other benefit of fig2ps is
that I sometimes have figures that are drawn in xfig. I can impose a
consistent look (same font, for example) on a set of figures (generated
by octave or xfig) by using fig2ps with forcespecial and other options,
as is done in the examples given by Jonathan and myself.

-Quentin



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------
Fabian Braennstroem
2005-10-27 17:35:22 UTC
Permalink
Hi Quentin,
Post by Quentin Spencer
Post by Jonathan Stickel
| > The best answer of the many | > provided involves the use of the
script fig2ps and a slight modification | > to the octave-forge
print.m function so that it generates fig files with | > "special"
text. | | fig2ps takes an option "--forcespecial" so that the text
need not be | "special" in the .fig file itself.
| | Another thing not yet mentioned is the use of sans serif fonts.
I | accomplish this with a "sans_fonts.sty" file which contains the
two lines
| | \renewcommand{\familydefault}{\sfdefault}
| \usepackage{sfmath}
| | where sfmath.sty I downloaded from
| | http://dtrx.de/od/tex/sfmath.html
| | fig2ps --add=type1cm,sans_fonts figure.fig
| | The package "type1cm" causes latex to use scalable fonts.
If you are using LaTeX, then why go through the extra fig file format?
Why not use the epslatex terminal?
jwe
We've had this conversation before :)
http://www.octave.org/mailing-lists/help-octave/2005/166
It is a matter of personal preference. I much prefer having
standalone, printable pdf figures. (I actually use 'fig2pdf' rather
than 'fig2ps.) These I include in latex documents with
"\includegraphics{}" rather than "\input{}". Another advantage is
that these figures are easy to submit when submitting documents to
journals.
When I discovered fig2ps (thanks to Jonathan, I believe), I also moved
away from using \input to using \includegraphics for the same reason.
The old way worked fine for my makefile-based way of creating latex
documents, but publishers always want self-contained figures that are
separate from the text of the document. The other benefit of fig2ps is
that I sometimes have figures that are drawn in xfig. I can impose a
consistent look (same font, for example) on a set of figures (generated
by octave or xfig) by using fig2ps with forcespecial and other options,
as is done in the examples given by Jonathan and myself.
The pstricks terminal should be a nice option too. And
convertig xfig figures there exist fig2pstricks.

It's my preference right now :-)

Greetings!
Fabian



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------
Quentin Spencer
2005-10-27 15:27:02 UTC
Permalink
Post by Jonathan Stickel
The best answer of the many provided involves the use of the script
fig2ps and a slight modification to the octave-forge print.m function
so that it generates fig files with "special" text.
fig2ps takes an option "--forcespecial" so that the text need not be
"special" in the .fig file itself.
Another thing not yet mentioned is the use of sans serif fonts. I
accomplish this with a "sans_fonts.sty" file which contains the two lines
\renewcommand{\familydefault}{\sfdefault}
\usepackage{sfmath}
where sfmath.sty I downloaded from
http://dtrx.de/od/tex/sfmath.html
fig2ps --add=type1cm,sans_fonts figure.fig
The package "type1cm" causes latex to use scalable fonts.
Well, it looks like we've all come up with different solutions to the
same problem. Some of this can be done on the (long) fig2ps command
line. The following command will switch all roman to sans-serif fonts:

fig2eps --forcespecial
--preamble=\\renewcommand{\\rmdefault}{\\sfdefault} figure.fig


-Quentin



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------
Henry F. Mollet
2005-10-27 20:47:16 UTC
Permalink
Presumably this is AquaTerm specific using font "Symbol, size" but here are
the four commands that create the Greek letters in subplot A of URL given
below.

gset label 1 " A) w/a = 3.0 " at 0.25, 27.5 font "Symbol,14"
%Since Greek Capital Alpha is same as Latin A, I can do it with one command
% to create Latin A and Greek omega/Greek alpha
gset label 20 "a" at 1.35, 17.5 font "Symbol,22" % Greek alpha
gset label 30 "Sa/" at 0.58, -8.7 font ", 18"
gset label 40 "l" at 0.74, -9 font "Symbol, 20" % Greek lambda
Henry
Post by Henry F. Mollet
http://homepage.mac.com/mollet/Demography/Fig1Aug42005.png
Not sure about subscripts and superscripts but Greek characters should work
in labels. Should work in titles also but I have not tried.
I was looking for the code but cannot find it and cannot remember because
it's not menu driven. I'll be searching because I want to know also how I
did it.
Henry
Hi -
Is it possible to get nicely-formatted titles and labels for plots like in
MATLAB? If I want a title to read "y = x2" I can type in "title('y = x^2')"
and it will output it as described before, or if I want a Greek character,
say
w, I can type "\omega" like in LaTeX. Is there some way to do this in Octave?
If so, how? Thanks.
-Ron Crummett
------------------------------------------------------------- Octave is
freely
http://www.octave.org/archive.html
-------------------------------------------------------------
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------

Loading...