[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #55707] plot(vector, scalar) is very slow

From: Hartmut
Subject: [Octave-bug-tracker] [bug #55707] plot(vector, scalar) is very slow
Date: Wed, 13 Feb 2019 06:21:20 -0500 (EST)
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:65.0) Gecko/20100101 Firefox/65.0


                 Summary: plot(vector, scalar) is very slow
                 Project: GNU Octave
            Submitted by: hardy
            Submitted on: Wed 13 Feb 2019 11:21:18 AM UTC
                Category: Plotting
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Performance
                  Status: None
             Assigned to: None
         Originator Name: 
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: 5.0.91
        Operating System: Any



I just unintenionally noticed, that plotting a scalar value versus a vector
takes incredibly long in Octave. Here is a small script to show what I mean:

close all

graphics_toolkit qt % fltk or gnuplot behave the very same

x = 1:1000; % vector
y = 10;     % scalar

plot(x, y);

First of all: I don't know if this usage of "plot(vector,scalar)" is
documented at all. But it doesn't throw any errors, neither in Octave nor in

Here are my timing results with the above script in Octave:
* Linux + Octave 4.4.1 (qt, fltk or gnuplot) -> 7 sec
* Linux + Octave 5.0.91 -> 7 sec
* Win 10 + Octave 4.4.1 (qt) -> 43 sec
* Win 10 + Octave 5.0.91 (qt, fltk or gnuplot) -> 50 sec
As a result Octave produces a plot window with 1000 differently colored little

Here is the result of the above script in Matlab:
* Win 10 + Matlab (probably V2017b or V2018b) -> 0.5 sec
Matlab produces a totally emtpy plot window as result.


In principle I like the current Octave behavior better than the Matlab one.
This could be a nice "Octave only" feature. If someone (like me in this case)
unintenionally plots only a single y value for a vector of x values it's quite
obvious what should be plotted. And the resulting Octave plot is fine for this
But: It takes incredibly long until the final plot apprears in the window. I
first did this under Windows 10, where it takes nearly a full minute!
Meanwhile I had already Ctrl-C'ed the script and started searching of a bug
somewhere. So in the current implementation, this "Octave only" feature is
disturbing the user. 

Possible solutions:

* (A) We could make this call to plot "illegal" and throw a (fast) error
message. (But Matlab doesn't).
* (B) We could do the same as Matlab, and return an empty plot window.
* (C) We could speed up our Octave plotting code for this special case by just
plotting a line. It assume this should be doable without too much coding,
because just using the following code is already fast enough: "plot(x,
y.*ones(size(x)))". This substitution code produces a line instead a series of
circles, which is (a) much faster, (b) kind of Matlab compatible and (c) as
helpful as the previous graphics output in my use case. But this might spoil
the graphical output for users who actually do want this serious of cirles
output. (What comes back to the question: Is the current Octave behavior
documented for this case? Do we want to stay backwards compatible if not?)
* (D) We could speed up our Octave plotting code and still generate a row of
circles. I am not sure how much work this would be, but I assume much more.


Reply to this item at:


  Message sent via Savannah

reply via email to

[Prev in Thread] Current Thread [Next in Thread]