Skip to content

Commit

Permalink
doc: clarify in the tutorial that bbox and margin works for Cairo…
Browse files Browse the repository at this point in the history
… only, closes #752
  • Loading branch information
ntamas committed Jan 30, 2024
1 parent 16c7379 commit fecc72c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion doc/source/tutorial.es.rst
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ Hmm, esto no es demasiado bonito hasta ahora. Una adición trivial sería usar l
>>> color_dict = {"m": "blue", "f": "pink"}
>>> g.vs["color"] = [color_dict[gender] for gender in g.vs["gender"]]
>>> ig.plot(g, layout=layout, bbox=(300, 300), margin=20) # Cairo backend
>>> ig.plot(g, layout=layout, bbox=(300, 300), margin=20, target=ax) # matplotlib backend
>>> ig.plot(g, layout=layout, target=ax) # matplotlib backend

Tenga en cuenta que aquí simplemente estamos reutilizando el objeto de diseño anterior, pero también hemos especificado que necesitamos un gráfico más pequeño (300 x 300 píxeles) y un margen mayor alrededor del grafo para que quepan las etiquetas (20 píxeles). El resultado es:

Expand Down
14 changes: 8 additions & 6 deletions doc/source/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -705,11 +705,12 @@ from the ``label`` attribute by default and vertex colors are determined by the
>>> color_dict = {"m": "blue", "f": "pink"}
>>> g.vs["color"] = [color_dict[gender] for gender in g.vs["gender"]]
>>> ig.plot(g, layout=layout, bbox=(300, 300), margin=20) # Cairo backend
>>> ig.plot(g, layout=layout, bbox=(300, 300), margin=20, target=ax) # matplotlib backend
>>> ig.plot(g, layout=layout, target=ax) # matplotlib backend

Note that we are simply re-using the previous layout object here, but we also specified
that we need a smaller plot (300 x 300 pixels) and a larger margin around the graph
to fit the labels (20 pixels). The result is:
Note that we are simply re-using the previous layout object here, but for the Cairo backend
we also specified that we need a smaller plot (300 x 300 pixels) and a larger margin around
the graph to fit the labels (20 pixels). These settings would be ignored for the Matplotlib
backend. The result is:

.. figure:: figures/tutorial_social_network_2.png
:alt: The visual representation of our social network - with names and genders
Expand Down Expand Up @@ -869,7 +870,8 @@ Keyword argument Purpose
---------------- ----------------------------------------------------------------
``bbox`` The bounding box of the plot. This must be a tuple containing
the desired width and height of the plot. The default plot is
600 pixels wide and 600 pixels high.
600 pixels wide and 600 pixels high. Ignored for the
Matplotlib backend.
---------------- ----------------------------------------------------------------
``layout`` The layout to be used. It can be an instance of
:class:`~layout.Layout`,
Expand All @@ -881,7 +883,7 @@ Keyword argument Purpose
``margin`` The top, right, bottom and left margins of the plot in pixels.
This argument must be a list or tuple and its elements will be
re-used if you specify a list or tuple with less than four
elements.
elements. Ignored for the Matplotlib backend.
================ ================================================================

Specifying colors in plots
Expand Down
2 changes: 1 addition & 1 deletion doc/source/visualisation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ Plotting graphs in Jupyter notebooks
|igraph| supports inline plots within a `Jupyter`_ notebook via both the `Cairo`_ and `matplotlib`_ backend. If you are
calling `igraph.plot` from a notebook cell without a `matplotlib`_ axes, the image will be shown inline in the corresponding
output cell. Use the `bbox` argument to scale the image while preserving the size of the vertices, text, and other artists.
For instance, to get a compact plot::
For instance, to get a compact plot (using the Cairo backend only)::

>>> ig.plot(g, bbox=(0, 0, 100, 100))

Expand Down

0 comments on commit fecc72c

Please sign in to comment.