So the axis ranges are linked to the viewbox of the plot so you will have to find a way to rotate the viewbox. Im going to see if I can figure that out real quick but posting this asap so you can look as well. At least I think this is what is happening. Only been working with pyqtgraph for 2 months or so
On Tuesday, July 25, 2017 at 4:49:57 PM UTC-6, m has wrote: > > 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] > <javascript:>> 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] <javascript:>. >> 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/bb606097-4a68-4232-8a7e-36304728f4fe%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
