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

Extent of axes dependent of order of points being shown #82

Closed
LucaMarconato opened this issue Jun 5, 2023 · 5 comments
Closed

Extent of axes dependent of order of points being shown #82

LucaMarconato opened this issue Jun 5, 2023 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@LucaMarconato
Copy link
Member

Changing the order of what is being rendered may alter the extent being shown in the plot.

Here below is not a way to reproduce the bug because it would be laborious, but it shows an example of what is going on. This code

        import matplotlib.pyplot as plt
        import spatialdata_plot

        # otherwise pre-commits will remove the "unused" import
        _ = spatialdata_plot

        ax = plt.gca()
        sdata.pl.render_shapes(element="by_polygons", na_color=(1.0, 0.7, 0.7, 0.5)).pl.show(ax=ax)
        sdata.pl.render_shapes(element="by_circles", na_color=(1.0, 0.7, 0.7, 0.5)).pl.show(ax=ax)
        sdata.pl.render_shapes(element="values_polygons", color="categorical_in_obs").pl.show(ax=ax)
        sdata.pl.render_shapes(element="values_circles", color="categorical_in_obs").pl.show(ax=ax)
        sdata.pl.render_points(color="categorical_in_ddf", size=10.0, palette="tab10").pl.show(ax=ax)
        # sdata.pl.render_shapes(element="values_circles", color="categorical_in_obs").pl.show(ax=ax) # <- this line is identical to the one 2 lines above!
        plt.show()

gives this plot:
image

If we uncomment the last line, we get this plot instead:
image

If we plot only the line that is commented in the code above, this is shown:
image

Expected behaviors:

  1. the final extent should not dependent of the order of elements being plot
  2. the expected extent is the screenshots above doesn't fit the actual extent of the data
@LucaMarconato
Copy link
Member Author

Note: I didn't look at the extent code but I saw a few PRs modifying it. If the problem arises because of edges cases of coordinate transformations I am happy to help refactoring the get_extent() code inside SpatialData.

@LucaMarconato
Copy link
Member Author

More details: I think the problem is in render_points().

@timtreis
Copy link
Member

timtreis commented Jun 8, 2023

Linking scverse/spatialdata#288

@timtreis timtreis self-assigned this Jun 8, 2023
@timtreis
Copy link
Member

timtreis commented Jun 9, 2023

Note from call with @LucaMarconato: When axs object is passed, check for current axes limit and, if needed, extend them but not overwrite.

@timtreis timtreis added the bug Something isn't working label Jun 9, 2023
@timtreis
Copy link
Member

timtreis commented Jun 9, 2023

@LucaMarconato can you try to reproduce your error?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants