Menu

#766 partial sample range specification in parametric mode

Version 5
open
nobody
None
5
2018-04-10
2018-04-10
No

On Japanese BBS, partial sample range specification is requested in parametric mode. For example,

set parametric
set trange [-pi:pi]
plot t,sin(t), [0:pi] t cos(t)

would draw a sin's graph for [-pi:pi] and a cos's graph for [0:pi].
I don't understand the code for range specification in plot2d.c well, but attached patch seems to do so.

1 Attachments

Discussion

  • Ethan Merritt

    Ethan Merritt - 2018-04-10

    I will look at the patch.

    In version 5 this kind of plot does not require parametric mode.
    Instead you can use the pseudofile '+':

     plot sample [t=-pi:pi] '+' using (t):(sin(t)), \
                 [t=0:pi] '+' using (t):(cos(t))
    

    That works in both versions 5.0 and 5.2 with no patches needed.

     

    Last edit: Ethan Merritt 2018-04-10
  • Shigeharu TAKENO

    Thanks for your reply.
    I know such workaround. It is for parametric mode he want to do.

     
  • Ethan Merritt

    Ethan Merritt - 2018-04-10

    Unfortunately I think that the current version of the patch is not complete enough to apply.

    One part is easy to fix: there is no need to copy and restore the entire axis_array[SAMPLE_AXIS] structure. It is sufficient to save and restore sampling_range_token.

    The more difficult problem is that most of the sample and partial range code in plot2d.c is in the sections handling data plots rather than function plots. The initialization, mapping, and cleanup of the sampling axis structures is incomplete for a function plot.

    For example, if you add a third plot to your test case:

      plot sample [t=-pi:pi] '+' using (t):(sin(t)), \
             [t=0:pi] '+' using (t):(cos(t)), \
             (t):(t)
    

    you will see that the 3rd plot inherits the partial range from the second plot rather than using the original xrange or trange. Adding "set trange" or "set xrange" does not change this.

    Another problem is that the code to prepare axis properties like logscale is not called. The failure is demonstrated by

       set xrange [1:6]
       set log x
       replot
    

    It is not simple to fix these problems. I think it is a better solution to use the data-plotting mode with '+' instead of parametric mode.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.