-
Notifications
You must be signed in to change notification settings - Fork 262
Matplotlib Container Artist #655
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
Conversation
|
@tacaswell I hereby summon you from the depths of the web! Please help us 🙇
https://github.com/networkx/grave/blob/944049f4fa639811b477e50e07ade5b5d1a0a7bb/grave/grave.py#L397 My understanding is that you instantiate the primitive children with some knowledge about their axes (e.g. via Thank you for your wisdom |
|
Actually, this is starting to work. We already inject the Onwards to vertex and edge labels, those are |
|
Alright, this now produces plots that make sense. Tests don't pass because of padding in the axes limits I believe. I'll track this down over the next few days. |
|
It's mostly the padding with the tests, but there are also a few legit failures with convex hull and post-draw editing. I think something is fishy about stale states for children. |
|
you sure the update of |
|
hehe good catch, I haven't finished refactoring the hull yet |
|
I will try to look at this tomorrow. |
|
Thanks @tacaswell Just to give you an overview of the current situation, it all works well except for graph_artist = GraphArtist(...)
vertex_artist = graph_artist.get_vertices()[0]
vertex_artist.set_facecolor("blue")
# this sets the vertex_artist.stale -> True, which then sets graph_artist.stale -> TrueEven though the bubbling of the |
|
That looks correct to me. The way rendering works in Matplotlib (leaving aside blitting) is always a complete re-render. That is in the case of the raster backends we start with an empty RGBA buffer and then composite everything in. The To that end you should also avoid marking things as stale during the There is also |
|
Thank you @tacaswell ! Any suggestions about the implementation of stuff like |
|
I implemented the import matplotlib.pyplot as plt
import igraph as ig
g = ig.Graph.Ring(5)
ig.plot(g, vertex_label=['a', 'b', 'c', 'd', 'e'], edge_label=['e1', 'e2', 'e3'], vertex_label_dist=1.1, vertex_label_angle=3.14/2)
plt.ion()
plt.show()makes: Then we can call: graphartist = plt.gca().get_children()[0]
graphartist.set(vertex_label_dist=1.5)and we get: We might want to document this feature somehow. In terms of drawing times, it does draw twice the first time, but then only once for each edit: the figure rotation thing was a misclick from my end, not a bug 😸 |
|
If you are using constrained layout it will draw twice (once to sort out how big everything is once to actually draw). I would not document digging into the axes artist list, it is better if I am also confused why the ring rotated and changed colors when you adjusted the label spacing.... |
|
Thanks @tacaswell .
|
|
Okay, I now checked that the rotation was not a bug, just me being silly. I also added a decorator to add a bunch of setter methods all at once, so you can I also back propagated the container artist up the caller stack until @natmas what do you think? Based on that I'll modify the user docs a little to include a tutorial where the new container artist is showcased and manipulated, to let the users know about their newly acquired powers. |
|
Hello from Okinawa! Shall we merge this? |
| "set_picker", | ||
| ) | ||
| ) | ||
| class Graph(Artist, AbstractGraphDrawer): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we rename this class to GraphArtist instead to avoid confusion with the Graph class (especially when this class starts to appear in the index of the API documentation, right next to the "real" Graph class).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we also need to rename the reference to this class from the tutorial if we decide to do the renaming.
|
I can rename, I'll be back next week and will do it |
|
I can do it myself and merge if you have no objections against it. |
|
That'd be great thank you!
…On Fri, Apr 21, 2023, at 18:08, Tamás Nepusz wrote:
I can do it myself and merge if you have no objections against it.
—
Reply to this email directly, view it on GitHub
<#655 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAJFEAEKFSQIOZLSL73ZRYLXCJFBRANCNFSM6AAAAAAWSFJGUU>.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
|
This seems to have broken the Readthedocs doc build, see here: https://readthedocs.org/projects/igraph/builds/20263052/ Any idea what's going on here @iosonofabio ? |
|
It looks like plotting an empty graph... Can fix within the week |
|
@iosonofabio Could this be related to this PR, any hints? --> #677 |


Back in September 2022 @tacaswell suggested looking into container artists as a way of tidying up our matplotlib code, e.g. in grave:
https://github.com/networkx/grave
While that repo is barely alive, it does have a proof of concept that could be used here.
The goal would be to have access to an object that represents the entire visual graph, something like:
It might take a while to get this in place, but I thought starting a draft does not hurt. Feedback welcome: on the idea for now, ignore the details of the code.
TODO:
PathCollections, we won't implement those for now, too much workcontainsandpickupcallbacksset(vertex_color=...)would apply to all vertices,set_vertex_color(...)would also apply to all vertices.