Discussion:
CurveDialog display right axis
Theschill
2012-05-08 19:25:05 UTC
Permalink
Hello,

I'm new to guiqwt and I am using the the CurveDialog Example to add
plots on both the left and right axis. I can get the curves to plot to
the right axis but the axis ticks and label do not appear until I go
to the axes parameters of the curve on the right axes and hit apply
(In this case, curve 2). After this, the right axis ticks and label
appears. Is there a wayto make the right axis visible without manually
opening the parameters dialog box and hitting apply?

Here is my modified code:
----------------------------------------------------------------------------------------------------------------------------
# -*- coding: utf-8 -*-
from guidata.qt.QtGui import QFont

from guiqwt.plot import CurveDialog
from guiqwt.builder import make

def plot(*items):
win = CurveDialog(edit=False, toolbar=True, wintitle="AMI Plot
Tool",
options=dict(title="Plot Title",
xlabel="xlabel",
ylabel=("Left Title", "Right
Title")))
plot = win.get_plot()
for item in items:
plot.add_item(item)
plot.set_axis_font("right", QFont("Courier"))
plot.set_axis_font("left", QFont("Courier"))
win.get_itemlist_panel().show()
plot.set_items_readonly(False)
win.show()
win.exec_()

def test():
"""Test"""
# -- Create QApplication
import guidata
_app = guidata.qapplication()
# --
from numpy import linspace, sin
x = linspace(-10, 10, 200)
y = sin(sin(sin(x)))
x2 = linspace(-10, 10, 20)
y2 = sin(sin(sin(x2)))
plot(make.curve(x, y, color="b", yaxis = "left"),
make.curve(x2, y2, color="g", curvestyle="Sticks", yaxis =
"right"),
make.curve(x, sin(2*y), color="r", yaxis = "left"))

if __name__ == "__main__":
test()
mauro
2012-05-11 08:40:00 UTC
Permalink
Hi everyone,
I have the same problem as Theschill and found no programmatic
solution. Could this be considered a bug?

An example of alternative implementation based on pyplot and plotyy is
below.

---------------------------------------------------

import guiqwt.pyplot as plt
import numpy as np
x = np.linspace(-5, 5, 1000)
plt.plotyy(x, np.sin(x), x, np.cos(x))
plt.ylabel("sinus", "cosinus")
plt.show()

---------------------------------------------------
Post by Theschill
Hello,
I'm new to guiqwt and I am using the the CurveDialog Example to add
plots on both the left and right axis. I can get the curves to plot to
the right axis but the axis ticks and label do not appear until I go
to the axes parameters of the curve on the right axes and hit apply
(In this case, curve 2). After this, the right axis ticks and label
appears. Is there a wayto make the right axis visible without manually
opening the parameters dialog box and hitting apply?
--------------------------------------------------------------------------- -------------------------------------------------
# -*- coding: utf-8 -*-
from guidata.qt.QtGui import QFont
from guiqwt.plot import CurveDialog
from guiqwt.builder import make
    win = CurveDialog(edit=False, toolbar=True, wintitle="AMI Plot
Tool",
                      options=dict(title="Plot Title",
xlabel="xlabel",
                                  ylabel=("Left Title", "Right
Title")))
    plot = win.get_plot()
        plot.add_item(item)
    plot.set_axis_font("right", QFont("Courier"))
    plot.set_axis_font("left", QFont("Courier"))
    win.get_itemlist_panel().show()
    plot.set_items_readonly(False)
    win.show()
    win.exec_()
    """Test"""
    # -- Create QApplication
    import guidata
    _app = guidata.qapplication()
    # --
    from numpy import linspace, sin
    x = linspace(-10, 10, 200)
    y = sin(sin(sin(x)))
    x2 = linspace(-10, 10, 20)
    y2 = sin(sin(sin(x2)))
    plot(make.curve(x, y, color="b", yaxis = "left"),
         make.curve(x2, y2, color="g", curvestyle="Sticks", yaxis =
"right"),
         make.curve(x, sin(2*y), color="r", yaxis = "left"))
    test()
Carlos Pascual
2012-05-14 06:41:11 UTC
Permalink
I can confirm the behaviour, and IMHO this is a bug.

An easy workaround is to call "plot.enable_used_axes()"
before calling win.show()
Post by mauro
Hi everyone,
I have the same problem as Theschill and found no programmatic
solution. Could this be considered a bug?
An example of alternative implementation based on pyplot and plotyy is
below.
---------------------------------------------------
import guiqwt.pyplot as plt
import numpy as np
x = np.linspace(-5, 5, 1000)
plt.plotyy(x, np.sin(x), x, np.cos(x))
plt.ylabel("sinus", "cosinus")
plt.show()
---------------------------------------------------
Post by Theschill
Hello,
I'm new to guiqwt and I am using the the CurveDialog Example to add
plots on both the left and right axis. I can get the curves to plot to
the right axis but the axis ticks and label do not appear until I go
to the axes parameters of the curve on the right axes and hit apply
(In this case, curve 2). After this, the right axis ticks and label
appears. Is there a wayto make the right axis visible without manually
opening the parameters dialog box and hitting apply?
-------------------------------------------------------------------------
-- ------------------------------------------------- # -*- coding: utf-8
-*-
from guidata.qt.QtGui import QFont
from guiqwt.plot import CurveDialog
from guiqwt.builder import make
win = CurveDialog(edit=False, toolbar=True, wintitle="AMI Plot
Tool",
options=dict(title="Plot Title",
xlabel="xlabel",
ylabel=("Left Title", "Right
Title")))
plot = win.get_plot()
plot.add_item(item)
plot.set_axis_font("right", QFont("Courier"))
plot.set_axis_font("left", QFont("Courier"))
win.get_itemlist_panel().show()
plot.set_items_readonly(False)
win.show()
win.exec_()
"""Test"""
# -- Create QApplication
import guidata
_app = guidata.qapplication()
# --
from numpy import linspace, sin
x = linspace(-10, 10, 200)
y = sin(sin(sin(x)))
x2 = linspace(-10, 10, 20)
y2 = sin(sin(sin(x2)))
plot(make.curve(x, y, color="b", yaxis = "left"),
make.curve(x2, y2, color="g", curvestyle="Sticks", yaxis =
"right"),
make.curve(x, sin(2*y), color="r", yaxis = "left"))
test()
--
+----------------------------------------------------+
Carlos Pascual Izarra
Scientific Software Coordinator
Computing Division
Cells / Alba Synchrotron [http:/www.cells.es]
Carretera BP 1413 de Cerdanyola-Sant Cugat, Km. 3.3
E-08290 Cerdanyola del Valles (Barcelona), Spain
E-mail: cpascual-***@public.gmane.org
Phone: +34 93 592 4428
+----------------------------------------------------+
Theschill
2012-05-14 13:17:18 UTC
Permalink
Carlos,

Thanks for the response! Workaround worked great!

-Kris
Post by Carlos Pascual
I can confirm the behaviour, and IMHO this is a bug.
An easy workaround is to call "plot.enable_used_axes()"
before calling win.show()
Post by mauro
Hi everyone,
I have the same problem as Theschill and found no programmatic
solution. Could this be considered a bug?
An example of alternative implementation based on pyplot and plotyy is
below.
---------------------------------------------------
import guiqwt.pyplot as plt
import numpy as np
x = np.linspace(-5, 5, 1000)
plt.plotyy(x, np.sin(x), x, np.cos(x))
plt.ylabel("sinus", "cosinus")
plt.show()
---------------------------------------------------
Post by Theschill
Hello,
I'm new to guiqwt and I am using the the CurveDialog Example to add
plots on both the left and right axis. I can get the curves to plot to
the right axis but the axis ticks and label do not appear until I go
to the axes parameters of the curve on the right axes and hit apply
(In this case, curve 2). After this, the right axis ticks and label
appears. Is there a wayto make the right axis visible without manually
opening the parameters dialog box and hitting apply?
-------------------------------------------------------------------------
-- ------------------------------------------------- # -*- coding: utf-8
-*-
from guidata.qt.QtGui import QFont
from guiqwt.plot import CurveDialog
from guiqwt.builder import make
    win = CurveDialog(edit=False, toolbar=True, wintitle="AMI Plot
Tool",
                      options=dict(title="Plot Title",
xlabel="xlabel",
                                  ylabel=("Left Title", "Right
Title")))
    plot = win.get_plot()
        plot.add_item(item)
    plot.set_axis_font("right", QFont("Courier"))
    plot.set_axis_font("left", QFont("Courier"))
    win.get_itemlist_panel().show()
    plot.set_items_readonly(False)
    win.show()
    win.exec_()
    """Test"""
    # -- Create QApplication
    import guidata
    _app = guidata.qapplication()
    # --
    from numpy import linspace, sin
    x = linspace(-10, 10, 200)
    y = sin(sin(sin(x)))
    x2 = linspace(-10, 10, 20)
    y2 = sin(sin(sin(x2)))
    plot(make.curve(x, y, color="b", yaxis = "left"),
         make.curve(x2, y2, color="g", curvestyle="Sticks", yaxis =
"right"),
         make.curve(x, sin(2*y), color="r", yaxis = "left"))
    test()
--
+----------------------------------------------------+
 Carlos Pascual Izarra
 Scientific Software Coordinator
 Computing Division
 Cells / Alba Synchrotron  [http:/www.cells.es]
 Carretera BP 1413 de Cerdanyola-Sant Cugat, Km. 3.3
 E-08290 Cerdanyola del Valles (Barcelona), Spain
 Phone: +34 93 592 4428
+----------------------------------------------------+
Loading...