Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update mpl drawer backend to support unshared axes #1242

Conversation

nkanazawa1989
Copy link
Collaborator

Summary

Experiment plotter can create a multi-sub canvas (axes) figure, but x and y plot range (xlim/ylim in matplotlib) must be shared among sub axes. This PR relaxes this limitation and allows a developer to write analysis class that can generate figure containing axes with different plot ranges.

Details and comments

Several figure options are updated to take a list of options for each axis. New options sharex and sharey are added to unlink the axis settings. These new options are True by default for backward compatibility.

Copy link
Collaborator

@yaelbh yaelbh left a comment

Choose a reason for hiding this comment

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

I'm approving because my comments don't have to block approval. For each of the comments, you are free to accept or reject it.

  1. Do you think "if there are multiple columns in the canvas" is clear enough?
  2. Instead of the lists limit, unit, etc. it's better to have a single list where each item has data members limit unit etc.
  3. Prefer zip over enumerate.
  4. Is there a reason that scale is excluded, i.e., always the same for all the sub-axes?

@nkanazawa1989
Copy link
Collaborator Author

Thanks @yaelbh. I'll merge this PR.

Do you think "if there are multiple columns in the canvas" is clear enough?

I'm not sure if this is enough, but this is from the original documentation. I found a typo and fixed in 1217836. Thanks!

Instead of the lists limit, unit, etc. it's better to have a single list where each item has data members limit unit etc.

This is good idea. Probably we can introduce cleaner subplot mechanism in a follow up PR, i.e. introducing a dataclass that stores subplot configuration, and set multiple dataclass instances to write multi-axis figure. This PR aims at implementation of minimal functionality for Stark experiment.

Prefer zip over enumerate.

Yes, this makes sense if we have such configuration dataclass. Writing zip for every configuration is bit lengthy.

Is there a reason that scale is excluded, i.e., always the same for all the sub-axes?

I'm not sure if I understand. Current implementation doesn't support axis-wide scaling. This is because if we allow such setup we need to optimize the margin between axes to have tick labels otherwise we cannot stack axes with different scaling option. Implementation is not difficult but overkill for Stark experiment. I'll create a follow up PR based upon request.

@yaelbh
Copy link
Collaborator

yaelbh commented Sep 19, 2023

Thanks @nkanazawa1989, can be merged when green.

@nkanazawa1989 nkanazawa1989 added this pull request to the merge queue Sep 19, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Sep 19, 2023
@nkanazawa1989 nkanazawa1989 added this pull request to the merge queue Sep 19, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Sep 19, 2023
@coruscating coruscating added this pull request to the merge queue Sep 19, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Sep 19, 2023
@nkanazawa1989 nkanazawa1989 added this pull request to the merge queue Sep 22, 2023
Merged via the queue into qiskit-community:main with commit 8355155 Sep 22, 2023
nkanazawa1989 added a commit to nkanazawa1989/qiskit-experiments that referenced this pull request Jan 10, 2024
…1242)

### Summary

Experiment plotter can create a multi-sub canvas (axes) figure, but x
and y plot range (xlim/ylim in matplotlib) must be shared among sub
axes. This PR relaxes this limitation and allows a developer to write
analysis class that can generate figure containing axes with different
plot ranges.

### Details and comments

Several figure options are updated to take a list of options for each
axis. New options ``sharex`` and ``sharey`` are added to unlink the axis
settings. These new options are True by default for backward
compatibility.
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.

2 participants