-
Notifications
You must be signed in to change notification settings - Fork 221
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
copying object to axes #113
Comments
Hi @kenziew, thanks for the feedback ! Normally you should be able to get the handles of the gramm axes through the gramm object itself after |
This is an old Issue but figured I'd check-in to see if you have advice/solutions since I think I want to do a similar thing described here and in #23 . Basically, I have drafted individual sub-figures (each sub-figure is a distinct gramm object with it's own faceting etc.) and now I want to simply "plug them in" to a new single figure without copying too much of the code. As a simple example: I have a gramm object for Fig 1a drawn in a figure, and another gramm object for Fig 1b drawn in a distinct figure. I want to create a single figure and assign the contents of Fig 1a to the first row of subplots and the contents of Fig 1b to the second row of subplots. I have tried using copy() as described in #23 to create a new gramm object containing both Fig 1a and Fig 1b but as that author of that Issue mentions, it seems that the handle references of gramm objects are tied to their figures so when I try to draw() my new gramm object the contents are drawn on distinct figures. Simpllified example code and output of what I’m trying to do follows:
The output is 3 figures. The Figure 3 (what I would expect to be combined 1+2) is blank. Interestingly the content and relative positions of Figure 1 and Figure 2 are what I’d like (Figure 1 is fig1a placed into row 1; Figure 2 is fig1b placed into row 2), but they aren’t being combined in a single figure. Appreciate any suggestions! |
Hi Dakota,
I can’t test things currently, but have you tried without calling the draw() function on the initial fig1a and fig1b objects ? I’m not sure how copy would interfere with that, but when drawing array of gramm objects a single draw call should be made on the whole array only.
|
Hi Pierre, Thanks for the prompt reply! I was able to get this to work by simply using the same MATLAB figure for all the gramm objects. In the old code above I use figure() to make a new figure before making each gramm object. If I just remove those figure() calls I get a single figure with my expected output (attached here). Now I'm working on adding some additional subplots with different faceting and getting them all aligned neatly (specifically a single graph in position fig1(3,1) and another in position fig1(3,2). I'm having some issues at this point, and am trying some stuff mentioned in #40 and #94 so when I get it worked out I can share my solution. |
Not sure where the best place to post this info is at this point (I’ve mentioned a few different Issues throughout and can make my own if that makes sense?) but wanted to share my solution in case it helps others: I think the copy() approach should work fine if you have similar faceting between plots (in my prior post, you can see that overall the figure layout looks good with just sub-figures 1 & 2, it just needs some text size adjustment and cleaning up). With this particular Figure though, once I tried to add sub-figures 3 & 4 I was trying to combine multiple gramm objects with different faceting. I ran into some issues just trying to copy() them. Though the gramm objects were drawing in the relatively correct spot, I couldn’t seem to get the layout neat. So, I decided to scrap that approach and use UIpanels as described in #40. This actually works really well (see final output fig) and I’d recommend others to just do this. Despite Pierre’s comment there that dynamic resizing is broken, I have found everything seems to be behaving very well for me. It requires pretty minimal editing of my existing code, just need to tweak the UIpanels to get a layout you like and set_parent() prior to the first draw call of each gramm object. This is the approach I plan to use for the rest of my Figures. @piermorel. thanks for making gramm, sharing it with us, and for taking the time to check-in on my comment! Gramm remains a great tool for anyone using MATLAB! |
First, this is awesome! Second, Is there any way to plot to a certain axes? I'm working in app designer and am trying to find a way to display the plot in the app axes but am not having luck with imhandles, copying the image, copyobj etc
The text was updated successfully, but these errors were encountered: