Skip to content

changed structure to redefine axis via plotitem.setAxes#391

Merged
j9ac9k merged 5 commits intopyqtgraph:developfrom
radjkarl:plotitem2
Jun 1, 2020
Merged

changed structure to redefine axis via plotitem.setAxes#391
j9ac9k merged 5 commits intopyqtgraph:developfrom
radjkarl:plotitem2

Conversation

@radjkarl
Copy link
Copy Markdown
Contributor

@radjkarl radjkarl commented Nov 10, 2016

this allows to redefine the plotItems axes after creation.

@codecov-io
Copy link
Copy Markdown

codecov-io commented Nov 10, 2016

Current coverage is 34.08% (diff: 89.47%)

Merging #391 into develop will increase coverage by 0.02%

@@            develop       #391   diff @@
==========================================
  Files           198        198          
  Lines         27249      27254     +5   
  Methods           0          0          
  Messages          0          0          
  Branches       4568       4569     +1   
==========================================
+ Hits           9280       9289     +9   
+ Misses        17143      17140     -3   
+ Partials        826        825     -1   

Powered by Codecov. Last update 4cdc3ac...6a2c2b8

self.plot(**kargs)


def setAxes(self, axisItems):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if self.axes is actually non empty when this method is called, should not they be removed from the layout before adding the new axes?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are right. changed that. see last commit.

@lesauxvi
Copy link
Copy Markdown
Contributor

OK, good to me. Do you agree @campagnola and @ericdill ?

NEW AxisItem.setOrientation (needed by plotitem.setAxes)
show/hide right axes after .setAxes()
self.label.setRotation(-90)
if self.orientation:
self._updateWidth()
self.setMaximumHeight(16777215)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this restores origin value

@radjkarl
Copy link
Copy Markdown
Contributor Author

setAxes should work now as expected

to try out this PR, please modify 'PlotWidget' example as follows:

ORIGINAL:
image

WITH ADDED CODE BEFORE LINE 'def rand(n):'
#swap axes
v = pw.plotItem
a1 = pw.getAxis('bottom')
a2 = pw.getAxis('left')
v.setAxes({'bottom': a2, 'left': a1})
image

WITH ADDED COSE BEFORE LINE 'def rand(n):'
#same with now axes at right:
v = pw.plotItem
a1 = pw.getAxis('bottom')
a2 = pw.getAxis('left')
v.setAxes({'bottom': a2, 'right': a1})
image

@j9ac9k
Copy link
Copy Markdown
Member

j9ac9k commented Jun 1, 2020

Thanks for the PR @radjkarl LTGM, merging, sorry it's taken so long for us to get to this.

@j9ac9k
Copy link
Copy Markdown
Member

j9ac9k commented Jun 8, 2020

Going to revert this PR due to some incompatibilities with PRs merged after this PR was created.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants