|
From: Mojca M. <moj...@gm...> - 2013-10-08 21:01:40
|
Dear developers,
I have just noticed the nice enhancement in gnuplot, defaulting to a
proper exponential form for numbers. However I have a tiny request.
I always use \cdot instead of \times. Would it be possible to make
this configurable?
This is the line in src/util.c that prints the character:
strcpy(&tmp2[j], "\\times");
The other "problem" I have if I would use this handy shortcut is that
it annoys me to have the y axis labelled "1", "1.5", "2", "2.5", ...
Thus I always use something like
set format y "%.1f"
I tried if I could use the same notation, "%.1h", but this only leads
to the undesired removal of dollar signs around the numbers (without
the desired effect), so I get:
2\times10^{43}
Is this removal of dollar signs intended?
I would really love to have a setting to turn on the functionality
that would automatically calculate the number of needed decimal places
and keep it constant on the whole axis. And possibly a similar setting
that would also stick with 1.0\times10^{0} to keep the numbers nicely
right-aligned when requested.
But if %h is available it would be really nice if it would at least
allow the explicit "%.<number>h".
Thank you,
Mojca
|
|
From: Ethan A M. <sf...@us...> - 2013-10-08 22:42:54
|
On Tuesday, 08 October, 2013 23:01:33 Mojca Miklavec wrote: > Dear developers, > > I have just noticed the nice enhancement in gnuplot, defaulting to a > proper exponential form for numbers. However I have a tiny request. > > I always use \cdot instead of \times. Would it be possible to make > this configurable? Yes. On the non-LaTeX side %h differs from %H by the choice of "x" versus ""*". It would make sense on the LaTeX side to interpret this as \times versus \cdot. Obviously only one of these can be the default. If you want something other than the default you have to use the "set format" command. > This is the line in src/util.c that prints the character: > strcpy(&tmp2[j], "\\times"); > > The other "problem" I have if I would use this handy shortcut is that > it annoys me to have the y axis labelled "1", "1.5", "2", "2.5", ... > Thus I always use something like > set format y "%.1f" That was one of two issues I had with the patch also. See discussion attached to the patch tracker. https://sourceforge.net/p/gnuplot/patches/637/ IMHO "%.1f" isn't quite right either. I prefer set format "%.1tx10^{%T}" The other side of the argument, and the rationale for the patch as written, is Craig DeForest's observation that some people actually like the %g format. That seems fair enough. I just don't happen to be one of those people. So %h is a variant of %g with improved markup. Arguably there is also room for a variant of %f with improved markup. > I tried if I could use the same notation, "%.1h", but this only leads > to the undesired removal of dollar signs around the numbers (without > the desired effect), so I get: > 2\times10^{43} > Is this removal of dollar signs intended? Yes. The dollar signs are only added automatically in the case of using the default format, so that the default state works for both LaTeX and non-LaTeX terminals. If you are going to the trouble of specifying an explicit "set format FOO" command then it's up to you to add whatever additional markup is needed, including dollar signs. > I would really love to have a setting to turn on the functionality > that would automatically calculate the number of needed decimal places > and keep it constant on the whole axis. And possibly a similar setting > that would also stick with 1.0\times10^{0} to keep the numbers nicely > right-aligned when requested. See discussion. I'd like that also, but it would require choosing the format at the level of the entire axis range, not tic-by-tic. > But if %h is available it would be really nice if it would at least > allow the explicit "%.<number>h". That doesn't work for %h exactly because it doesn't work for %g. Ethan |
|
From: Mojca M. <moj...@gm...> - 2013-10-09 13:26:37
|
On Wed, Oct 9, 2013 at 12:41 AM, Ethan A Merritt wrote:
>
>> I always use \cdot instead of \times. Would it be possible to make
>> this configurable?
>
> Yes.
> On the non-LaTeX side %h differs from %H by the choice of "x" versus ""*".
> It would make sense on the LaTeX side to interpret this as \times versus \cdot.
>
> Obviously only one of these can be the default.
> If you want something other than the default you have to use the
> "set format" command.
What about something more in the spirit of decimalsign?
set decimalsign ','
So something like
set multiplicationsign '*'
and the code in TERM_IS_LATEX checking for the value of that
character: if equal to '*', it would replace it with '\cdot', but in
principle users could use anything, from normal dots to '\bigtimes' or
anything else they please to use.
This would allow a much better flexibility, also because one wouldn't
need to change the format at all. With your suggestion one would need
to set both
set format x "%H"
set format y "%H"
and maybe at some other places displaying numerical values while
setting multiplication sign could be done once and for all.
>> This is the line in src/util.c that prints the character:
>> strcpy(&tmp2[j], "\\times");
>>
>> The other "problem" I have if I would use this handy shortcut is that
>> it annoys me to have the y axis labelled "1", "1.5", "2", "2.5", ...
>> Thus I always use something like
>> set format y "%.1f"
>
> That was one of two issues I had with the patch also.
> See discussion attached to the patch tracker.
> https://sourceforge.net/p/gnuplot/patches/637/
Thank you. I believe that your comment:
"I think the only way to get consistent formatting is to look at
all the tic values first and then pick some single format that can be
used for all of them."
expresses the same feelings that I have.
Yes, I hate if the axes are labelled "0.1000", "0.2000", "0.2999",
"0.4000" which might happen with "%f", but users should really have a
way of getting a consistent number of decimal digits. Even if some
people prefer "%g" (I often use %g only because I'm too lazy to
specify how many numbers I want exactly and this usually prints
something that makes more sense than %f), there should be a way to get
"0.00", "0.05", "0.10", "0.15", ... automatically. Yes, using "%.2f"
is a viable workaround, but one needs to hardcode the number of
desired decimal places. I would really love to see that number being
calculated automatically.
Btw: how does the current code deal with cases such as:
a) 0.001, 0.01, 0.1, 1, 10, 100, 1000, 10000
b) 100, 200, 300, ..., 900, 1000, 1100
When does the code decide to use exponential notation and when would
it print a normal "1000" rather than 1x10^3?
> IMHO "%.1f" isn't quite right either. I prefer
> set format "%.1tx10^{%T}"
>
> The other side of the argument, and the rationale for the patch
> as written, is Craig DeForest's observation that some people actually
> like the %g format. That seems fair enough. I just don't happen to
> be one of those people.
Me neither. And most other programs use a consistent number of decimal
places for axes labeling. The compromise is to allow both, but I don't
know how complex it would be to support that.
>> I would really love to have a setting to turn on the functionality
>> that would automatically calculate the number of needed decimal places
>> and keep it constant on the whole axis. And possibly a similar setting
>> that would also stick with 1.0\times10^{0} to keep the numbers nicely
>> right-aligned when requested.
>
> See discussion. I'd like that also, but it would require choosing the
> format at the level of the entire axis range, not tic-by-tic.
True, it's needed for the entire range, not just by looking at a
single tick. I don't know enough about gnuplot internals to be able to
judge what changes exactly that would require.
Mojca
|
|
From: Ethan A M. <sf...@us...> - 2013-10-09 17:42:00
|
On Wednesday, 09 October, 2013 15:26:29 Mojca Miklavec wrote: > > What about something more in the spirit of decimalsign? > set decimalsign ',' That doesn't really seem any easier than "set format". Either way you have to specify what you want if it's not already the default. > This would allow a much better flexibility, also because one wouldn't > need to change the format at all. With your suggestion one would need > to set both > set format x "%H" > set format y "%H" > and maybe at some other places displaying numerical values while > setting multiplication sign could be done once and for all. "set format '%H'" is sufficient. You don't need to set it separately for x and y. A related question: At the moment the new code checks for TERM_IS_LATEX and if so replaces the default format "%h" with "$%h$". I.e. it uses the same format but wraps it in $...$ so that LaTeX uses numerical mode. Would it be a good idea to _always_ do this? Or maybe always do it if the format does not already contain $ signs? Ethan |
|
From: Christoph B. <us...@be...> - 2013-10-10 12:46:03
|
Am 09.10.2013 19:36, schrieb Ethan A Merritt: > > At the moment the new code checks for TERM_IS_LATEX and if so > replaces the default format "%h" with "$%h$". I.e. it uses the same > format but wraps it in $...$ so that LaTeX uses numerical mode. > Would it be a good idea to _always_ do this? Or maybe always do > it if the format does not already contain $ signs? You could wrap the format in $...$ only if it contains only formatting specifiers (%...), and these mustn't output any letter (the 'e' in the scientific notation should by typeset upright etc.). This would also break, if one uses macros to format the labels. Christoph |
|
From: Mojca M. <moj...@gm...> - 2013-10-10 12:19:19
|
On Wed, Oct 9, 2013 at 7:36 PM, Ethan A Merritt wrote:
> On Wednesday, 09 October, 2013 15:26:29 Mojca Miklavec wrote:
>>
>> What about something more in the spirit of decimalsign?
>> set decimalsign ','
>
> That doesn't really seem any easier than "set format".
> Either way you have to specify what you want if it's not already
> the default.
>
>> This would allow a much better flexibility, also because one wouldn't
>> need to change the format at all. With your suggestion one would need
>> to set both
>> set format x "%H"
>> set format y "%H"
>> and maybe at some other places displaying numerical values while
>> setting multiplication sign could be done once and for all.
>
> "set format '%H'" is sufficient. You don't need to set it separately for x and y.
It's not just about simplicity, but also about configurability. Let's
say that a user would want
3×10<sup>6</sup>
rather than
3x10<sup>6</sup>
even if UTF-8 isn't recognized.
If a particular user will want a dot (1.10^12) or a bit of extra space
around the multiplication sign or some other weird character, this
would be easy to do. And you would also pollute less letter space: %H
could be used later for a different meaning.
> A related question:
>
> At the moment the new code checks for TERM_IS_LATEX and if so
> replaces the default format "%h" with "$%h$". I.e. it uses the same
> format but wraps it in $...$ so that LaTeX uses numerical mode.
> Would it be a good idea to _always_ do this? Or maybe always do
> it if the format does not already contain $ signs?
What exactly do you mean with "always"? If I use "set title 'some
text'" I don't want it to be enclosed in dollar signs for example.
Which cases exactly fall under "alway wrap it in $...$"?
In my old scripts I was often using something like (please excuse me
if I used the wrong format specifiers here):
set format y "\\m{%t}{%T}"
where the master document defined
\def\m#1#2{$#1\cdot10^{#2}$}
I guess this would fail then?
The reason why I did this was because specifying
set format y "$%t\\cdot10^{%T}$"
led to cca. 12 extra characters in calculation of the string length
and I ended up with way too much empty space. I believe this space
calculations is partially fixed now (even though still not perfect).
Mojca
|
|
From: sfeam <sf...@us...> - 2013-10-10 15:36:26
|
On Thursday, October 10, 2013 02:19:12 PM Mojca Miklavec wrote:
> On Wed, Oct 9, 2013 at 7:36 PM, Ethan A Merritt wrote:
> > On Wednesday, 09 October, 2013 15:26:29 Mojca Miklavec wrote:
> > "set format '%H'" is sufficient. You don't need to set it separately for
> > x and y.
> It's not just about simplicity, but also about configurability. Let's
> say that a user would want
> 3×10<sup>6</sup>
> rather than
> 3x10<sup>6</sup>
> even if UTF-8 isn't recognized.
Huh? How can you select a UTF-8 character if UTF-8 isn't recognized?
> > A related question:
> >
> > At the moment the new code checks for TERM_IS_LATEX and if so
> > replaces the default format "%h" with "$%h$". I.e. it uses the same
> > format but wraps it in $...$ so that LaTeX uses numerical mode.
> > Would it be a good idea to _always_ do this? Or maybe always do
> > it if the format does not already contain $ signs?
>
> What exactly do you mean with "always"? If I use "set title 'some
> text'" I don't want it to be enclosed in dollar signs for example.
Only for "set format"
> Which cases exactly fall under "alway wrap it in $...$"?
>
> In my old scripts I was often using something like (please excuse me
> if I used the wrong format specifiers here):
> set format y "\\m{%t}{%T}"
> where the master document defined
> \def\m#1#2{$#1\cdot10^{#2}$}
That example is way over my head.
I don't recognize the syntax at all.
> I guess this would fail then?
Yes it would. So maybe it it wasn't a good idea.
I can revert it to only wrap the default format, not user-defined formats.
Ethan
|
|
From: Mojca M. <moj...@gm...> - 2013-10-11 06:42:22
|
On Thu, Oct 10, 2013 at 5:28 PM, sfeam wrote:
> On Thursday, October 10, 2013 02:19:12 PM Mojca Miklavec wrote:
>
>> It's not just about simplicity, but also about configurability. Let's
>> say that a user would want
>> 3×10<sup>6</sup>
>> rather than
>> 3x10<sup>6</sup>
>> even if UTF-8 isn't recognized.
>
> Huh? How can you select a UTF-8 character if UTF-8 isn't recognized?
1. The character exists in many iso-8859-x encoding, also in
cp1250/cp1252 for example (I didn't try to do extensive checks to see
where else), but it is encoded differently (it's still D7, but it
consists of a single byte rather than two bytes like in UTF-8). So you
actually just reminded me of an additional case where the user might
want to change the sign: to use multiplication sign under a different
encoding (of course the code could also be improved to recognize
different encodings and print the proper character for them).
2. I don't have a clean overview of different terminals, but LaTeX,
ConTeXt & related terminals don't need to set the UTF-8 or any other
encoding for that matter to be usable. Imagine for a while a terminal
that outputs plain text (like LaTeX does), but doesn't set
TERM_IS_LATEX that would substitute the character for "\times". I
often created *.plt scripts in cp1250, I used cp1250-encoded strings
in "set title" and I used "\usepackage[cp1250]{inputenc}" in the main
LaTeX document which included the plot. That created perfectly usable
files with all the non-ascii characters properly encoded, without
setting an explicit encoding in gnuplot. Gnuplot was just piping the
characters through and everything worked. I believe in such a mode
(without explicitly setting some encoding) there is currently no way
to get the proper multiplication sign.
>> > A related question:
>> >
>> > At the moment the new code checks for TERM_IS_LATEX and if so
>> > replaces the default format "%h" with "$%h$". I.e. it uses the same
>> > format but wraps it in $...$ so that LaTeX uses numerical mode.
>> > Would it be a good idea to _always_ do this? Or maybe always do
>> > it if the format does not already contain $ signs?
>>
>> What exactly do you mean with "always"? If I use "set title 'some
>> text'" I don't want it to be enclosed in dollar signs for example.
>
> Only for "set format"
>
>> Which cases exactly fall under "alway wrap it in $...$"?
>>
>> In my old scripts I was often using something like (please excuse me
>> if I used the wrong format specifiers here):
>> set format y "\\m{%t}{%T}"
>> where the master document defined
>> \def\m#1#2{$#1\cdot10^{#2}$}
>
> That example is way over my head.
> I don't recognize the syntax at all.
I basically achieved the same output as the new code. It is just that
I asked gnuplot to print
\m{3}{5}
or maybe
3\E{5}
into the label and LaTeX ended up typesetting
$3\cdot10^{5}$
Gnuplot saw 6 or 8 characters instead of 14 which made the labels
considerably smaller. (Before LaTeX had its own way of counting
characters which is still not perfect.)
>> I guess this would fail then?
>
> Yes it would. So maybe it it wasn't a good idea.
> I can revert it to only wrap the default format, not user-defined formats.
The main question is whether it can be reverted easily be the user
(whether user can turn it of it becomes annoying). Another flaw of
always putting the dollar signs around the labels (other than users
putting TeX commands there which add dollar signs themselves - like my
example above) is the use of comma as a decimal separator which
introduces extra space when in text mode (unless instructed
differently). So "$3,5$" basically becomes "3, 5" when typeset.
Now again, gnuplot could try to be "smart enough" to replace "$3,5$"
by "$3{,}5$", the only question is when this all ends and when it
starts interfering with users who know exactly what they are doing. I
need to check what happens with a combination of %h and decimal comma
right now.
Mojca
|