octave-bug-tracker
[Top][All Lists]
Advanced

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

[Octave-bug-tracker] [bug #61087] PLOT function produces incorrect graph


From: Trevor
Subject: [Octave-bug-tracker] [bug #61087] PLOT function produces incorrect graph.
Date: Sat, 28 Aug 2021 13:40:45 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0

URL:
  <https://savannah.gnu.org/bugs/?61087>

                 Summary: PLOT function produces incorrect graph.
                 Project: GNU Octave
            Submitted by: ipa
            Submitted on: Sat 28 Aug 2021 05:40:43 PM UTC
                Category: Plotting
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Incorrect Result
                  Status: None
             Assigned to: None
         Originator Name: Trevor
        Originator Email: 
             Open/Closed: Open
                 Release: 6.3.0
         Discussion Lock: Any
        Operating System: GNU/Linux

    _______________________________________________________

Details:

I've encountered a bug in the Octave PLOT function, when plotting some
scientific data.  I've created below a stripped down demo code to demonstrate
the problem with synthetic data.

The demo code produces two figures with comparable data, one showing the
problem, one not.  The data produces a straight line graph in fig1, but in
fig2 produces an error and displays a staircase waveform instead.  Also the
xgrid is non-uniform & poorly labelled, and the y-axis labelling is poorly
positioned.

The problem appears to be triggered when the data on one axis has a moderately
large mean value, but small dynamic range.  And it occurs whether it is x data
or y data.

I've checked this on the following platforms, all with the same result:

Linux Oct 6.3 (Flatpack)
Linux Oct 5.2 (Native)
Win10 Oct 6.1

I've plotted the same data with Python (code attached) and it plots correctly
with no error.  Unfortunately I no longer have access to Matlab, but I would
expect it to plot correctly also.

I suspect the problem may be that the plot function is not properly
considering the graph limits, to plot the data with the correct resolution.

Please could a fix be made.

Regards, Trevor



OCTAVE DEMO CODE

function retval = plterr()
  
  close all;
  
  x=[0:0.001:1];
  y=[0:0.001:1];
  k=700000;

  h1=figure;      % This plots OK
  plot(x, y);
  grid on; 
 
  x=x+k;          % Add offset to data
  
  h2=figure;      % This plots INCORRECTLY
  plot(x, y);
  grid on;
    
end


PYTHON DEMO CODE

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Aug 28 13:22:20 2021

@author: trevor
"""

import numpy as np
import matplotlib.pyplot as plt

x = np.linspace(0,1,num=1000)+700000
y = np.linspace(0,1,num=1000)

plt.figure(num=0,dpi=120)
plt.plot(x, y)






    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?61087>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

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