Dear Patrik, Thanks again for your valuable input. I also realized that probably it is not simple enought to just change axis in pyqtgraph. Normally you have plots with x-axis(horizontal) for time and y-axis(vertical) for some pysical quantity.
But in case of ADAS Autosar, the axis are different. Here x-axis(vertical) represent the distance along drive path for car and y-axis(horizontal) represents the lateral distance. So thats why i need a axis orientation like this to plot objects around car field of view. I will look into it again, and if I come up with some solution, I will post it here. Has On Wednesday, 26 July 2017 19:41:18 UTC+2, Patrick Kreitzberg wrote: > > The axis is linked to the viewbox so I am not sure if what you want can be > done or not. Rotating the viewbox causes a mess. This is probably an > issue you will just have to work around by setting the axis range to > variables that are named according to how you want and updating those, or > whatever solution you want but I don't think pyqtgraph can do this natively. > > If it helps, the viewbox function .childrenBounds() returns the xrange, > yrange as you want them so that xrange is the range on the left axis and > yrange is the range on the bottom axis. If you can get the graph to update > so that the viewbox left axis is the same as the child left axis then what > you want to do will be done. Not sure how to do that. Maybe Ill look when > I am not at work. > > > 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]> 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/f5f74f8b-f744-4abd-92a3-721733efb3e0%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
