Dear Patrik,
Thank you again for your detailed reply. Indeed the coordinates sytem
appers to be rotated. Now if I try to set min, max limits on new
X-axis(vertical), unfortunately it sets the limit to old axis(horizontal).

Best Regards,
 Haseeb

On 26 Jul 2017 00:35, "Patrick Kreitzberg" <[email protected]> wrote:

> My description was off, the x axis is on the left but is labeled 'Y'.  The
> y axis is on the bottom labeled as 'X'.
>
> The graph is rotated 90 degrees and the bottom axis is inverted.
>
> On Tuesday, July 25, 2017 at 12:22:06 PM UTC-6, Patrick Kreitzberg wrote:
>>
>> Is the following what you want? It has the x axis is on the left side,
>> labeled as the x axis and increases as you go up.  The y axis is on the
>> bottom, is labeled the y axis and increases *to the left*.
>>
>> Done by setting the plotwidget to have invertX=true which is actually a
>> property of the PlotItem created by the plotwidget. Then the graph is
>> rotated 90 degrees and the PlotItem axis's are labeled as you want.
>>
>> from pyqtgraph.Qt import QtGui, QtCore
>> import numpy as np
>> import pyqtgraph as pg
>> app = QtGui.QApplication([])
>> mw = QtGui.QMainWindow()
>> win = pg.PlotWidget()
>> x = np.arange(0, 2*np.pi, 0.1)
>> y = np.sin(x)
>> l = pg.PlotDataItem(x=x,y=y)
>> win.addItem(l)
>>
>> win.getPlotItem().invertX(True)
>>
>> cw = QtGui.QWidget()            # GENERIC WIDGET AS CENTRAL WIDGET
>> (inside main window)
>> lay = QtGui.QGridLayout()
>> cw.setLayout(lay)
>> lay.addWidget(win)
>>
>> l.rotate(90)
>> ax = win.getPlotItem().getAxis('left')
>> ax.setLabel('Y')
>> ax = win.getPlotItem().getAxis('bottom')
>> ax.setLabel('X')
>>
>> mw.setCentralWidget(cw)
>> mw.show()
>> if __name__ == '__main__':
>>     import sys
>>     if (sys.flags.interactive != 1) or not hasattr(QtCore,
>> 'PYQT_VERSION'):
>>         QtGui.QApplication.instance().exec_()
>>
>> On Monday, July 24, 2017 at 10:31:19 AM UTC-6, m has wrote:
>>>
>>> Is there any way to swap x-axis and y-axis in plot. I need a vertical
>>> x-axis and horizontal y-axis. I can not simply plot(y,x) as I need to set
>>> alot of other properties as well. I have been searching for two days but no
>>> avail. I rotated the ViewBox, but it changes the x-axis and y-axis labels.
>>>
>>> Thank you.
>>>
>> --
> You received this message because you are subscribed to a topic in the
> Google Groups "pyqtgraph" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/pyqtgraph/LPpYZrDvZpA/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/pyqtgraph/c28befb7-c8a7-48ed-8e34-f96243db4af4%40googlegroups.com
> <https://groups.google.com/d/msgid/pyqtgraph/c28befb7-c8a7-48ed-8e34-f96243db4af4%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pyqtgraph/CACEzMm5noV16540Vd-32mz%2BR7z5uHPzHYPkNi1vCPhoYq6Zo%2BQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to