Git Product home page Git Product logo

Comments (13)

Samreay avatar Samreay commented on September 16, 2024 2

@jacobseiler Alright, I'll see if I can add that in over the next couple of days.

@manodeep They're not the same - axes would be a (nxn) list, fig.axes returns a flattened list. But inside the lists the references are the same. You can compare the id's to confirm with the below snippet:

import matplotlib.pyplot as plt
fig, axes = plt.subplots(2,2)
axes2 = fig.axes
print(axes)
print(axes2)

from chainconsumer.

Samreay avatar Samreay commented on September 16, 2024 2

Check out the plot_contour method in v0.29.0

Example here: https://samreay.github.io/ChainConsumer/examples/customisations/plot_axis.html

Reopen if there are any issues :)

from chainconsumer.

manodeep avatar manodeep commented on September 16, 2024 1

Thanks @tmcclintock. I am trying to minimize the amount of coding involved. I was thinking of adding in a return_axes keyword, disabled by default, that returns the used axes when requested explicitly.

@Samreay Would such a design work?

from chainconsumer.

Samreay avatar Samreay commented on September 16, 2024

from chainconsumer.

manodeep avatar manodeep commented on September 16, 2024

While this issue is a few years old, would still be a fairly useful feature to have. What's required to implement this?

from chainconsumer.

tmcclintock avatar tmcclintock commented on September 16, 2024

It appears that most of the work would involve reworking some of the Plotter object. At present, it internally creates the figure and axes for each of the plotting routines (just ctrl-f for "subplots").

It would be straightforward to make those optional arguments in the function, and only a bit annoying to check that the extents of the incoming axes satisfy what is required in each routine.

from chainconsumer.

Samreay avatar Samreay commented on September 16, 2024

Manodeep, my main concern with the first comment is that it only works when you're trying to plot the contour of 2 parameters. What is the use case when people want 3 parameters? Or two with histograms? Does matplotlib allow axes to have sub-axes, so to speak?

Im not following how adding a return_axes keyword would help. Are you suggesting chainconsumer would return axes? It returns the figure already, from which you get the axes, so I feel like I have missed the point, can you elaborate?

from chainconsumer.

jacobseiler avatar jacobseiler commented on September 16, 2024

+1-ing for adding an axis keyword for plotting.

I have a Figure with multiple subplots and on each of those subplots I want to just tell ChainConsumer "Hey, only plot the contours on this specific axis, literally don't do anything else".

While I could use ChainConsumer to make multiple different figures and then stitch them together in post, it feels like a round-a-bout and hacky solution.

from chainconsumer.

manodeep avatar manodeep commented on September 16, 2024

@Samreay Realised that I never responded to your comment.

I am not sure how to retrieve the axes from the figure object. Do you mind showing an example?

from chainconsumer.

Samreay avatar Samreay commented on September 16, 2024

@jacobseiler so maybe the best usecase is you pass in an axis (maybe to a different method) and say - plot the contour of these two parameters here please and thats all it does. That could work without too much hassle I think!

@manodeep I believe this should work axes = fig.axes

from chainconsumer.

manodeep avatar manodeep commented on September 16, 2024

@Samreay I have tried that in ipython. From what I recall, the ipython autocomplete implied that the fig.axes was not the same as what you would get from plt.subplot. For instance, can you confirm that fig.axes and axes are the same object in this line?

from chainconsumer.

jacobseiler avatar jacobseiler commented on September 16, 2024

@Samreay That sounds like the best option. Since I don't do heavy statistical analysis or corner style plots or anything fancy, I honestly use ChainConsumer to just easily plot contours.

Having a method that literally just accepts an axis and plots 2-parmater contours on the axis, without touching any labels/ticks/resizing/etc, would be perfection.

from chainconsumer.

manodeep avatar manodeep commented on September 16, 2024

@Samreay Many thanks!

from chainconsumer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.