|
From: Mojca M. <moj...@gm...> - 2009-07-21 16:45:28
|
On Tue, Jul 21, 2009 at 17:45, Ethan Merritt wrote:
> On Tuesday 21 July 2009, Mojca Miklavec wrote:
>> On Tue, Jul 21, 2009 at 14:39, Thomas Sefzick wrote:
>> >
>> > set xrange [] noreverse
>>
>> Thanks. But shouldn't it change back automatically?
>>
>> It automatically changes to "reverse" as soon as one uses [more:less],
>> but doesn't automatically change back.
>
> I tend to agree with you on this point, but...
>
>> I mean ...
>>
>> > show xrange
>> set xrange [ * : * ] noreverse nowriteback # (currently [-10.0000:10.0000] )
>> > plot [0:10] sin(x)
>> > show xrange
>> set xrange [ * : * ] noreverse nowriteback # (currently [0.00000:10.0000] )
>> > plot sin(x)
>> # only "currently" changes, but gets restored as soon as one drops
>> using explicit [:]
>> > show xrange
>> set xrange [ * : * ] noreverse nowriteback # (currently [-10.0000:10.0000] )
>> > plot [10:0] sin(x)
>> > show xrange
>> set xrange [ * : * ] reverse nowriteback # (currently [10.0000:0.00000] )
>> > plot sin(x)
>> # in my opinion this should become "noreverse" automatically
>
> there I completely disagree. You set the range to be [10:0], and for a
> subsequent plot to silently change that is a really bad idea.
>
> IMHO the real problem is that placing a range in the plot command itself
> plot ... [foo:baz] ...
> does not have an obvious meaning.
> Does that range apply to only the clause it appears in?
> Does it apply to the entire plot command?
> Does it persist after the plot command?
It (almost) never does.
plot [foo:baz] something
plots betwee foo and baz. In next plot this setting is (always) forgotten.
When working with data files one usually doesn't want to have xrange
defined, so one alternative is to use
set xrange [foo:baz]
plot sin(x)
set xrange restore
plot 'a.dat'
as opposed to
plot [foo:baz] sin(x)
plot 'a.dat'
but I prefer the second one (much shorter). Since one cannot set
"subrange" of plots anyway, i.e.
plot 'a.dat', [0:1] f(x)
doesn't work, one needs to use
plot 'a.dat', (x>=0 && x<=1) ? f(x) : 1/0
instead, the "plot [foo:baz]" seem very well defined to me, but I
might be missing some weird cases (multiplots?) that I don't know
well.
> Does it affect the value of variables evaluated during the plot command?
>
> Yes, it is possible to determine the answers to these questions by experimentation,
> but it seems to me that the better approach is simply not to use this construct.
> There are no such ambiguities associated with an explicit
> set xrange [foo:baz];
> plot ...
Sure, but see above. That means almost twice as much typing.
The fact is that one almost never needs reversed axis, so the issue
hardly affects anyone and therefore has a low priority anyway. (I
purely accidentally deleted one chacater too much when specifying the
range and have been bitten by that unexpected behaviour. I don't
expect myself to be affected in any other circumstances.)
I would call it a tiny bug, but whether it's worth fixing (or if it's
considered a bug at all) still depends on developers.
Mojca
>> # unless someone uses "set xrange [] reverse" by explicitely calling it
>> > show xrange
>> set xrange [ * : * ] reverse nowriteback # (currently [10.0000:-10.0000] )
>>
>> I didn't check internals, but maybe a separate variable is needed to
>> track "current reverse" just as there is "current range" after #.
>>
>> Mojca
>>
>> > Mojca Miklavec wrote:
>> >>
>> >> Hello,
>> >>
>> >> I accidentally used "plot [bigger:smaller]", but when I corrected the
>> >> mistake, the plotting range didn't restore to the appropriate value.
>> >> Would it make sense to fix that behaviour?
>> >>
>> >> Example:
>> >>
>> >> # ok
>> >> plot [0:10] sin(x)
>> >> # ok
>> >> plot [10:0] sin(x)
>> >> # wrong; plots as [10:0]; "set xrange restore" doesn't help; only "reset"
>> >> does
>> >> plot [0:10] sin(x)
>> >>
>> >> Thanks,
>> >> Mojca
|