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

Label Font, Arrow Pointing to Node Edge, Plots integration #150

Open
willsharpless opened this issue Jul 26, 2021 · 3 comments
Open

Label Font, Arrow Pointing to Node Edge, Plots integration #150

willsharpless opened this issue Jul 26, 2021 · 3 comments

Comments

@willsharpless
Copy link

Hi,

This is a sweet package, thanks for your hard work writing it. I had a couple questions/requests about looks,

  1. It would be really awesome if the node/edge labels could be LaTeXStrings. The times new roman font for the labels really downgrades the images given that I intend to use these plots for journal figures.

  2. Is there a way to make the directed graph arrows point to the surface of nodes? Currently, I see this sloppy behavior where some sizes of nodes overlap with the end of the arrow, and I can't find any kw arg to fix it:
    image

  3. This package would be much more desireable if graph plots could be integrated into Plots. Maybe there is a way I don't see from the basic usage, but the only way I seem to be able to put these graphs with other plots in Plots.jl is by saving them as images, which feels gratuitous and rigid. I understand this might be a complex suggestion, but it would make a large difference.

Thanks again!

@hdavid16
Copy link
Contributor

hdavid16 commented Jul 27, 2022

Great suggestions:

  1. This is an issue with Compose.jl, which is used by both GraphPlot.jl and Gadfly.jl: Support LaTeXStrings.jl GiovineItalia/Gadfly.jl#1094

  2. Agreed, this should be fixed and will require editing the logic in graphline and graphcurve so that endx and endy account for the edge linewidth rather than just the nodesize (

    endx = locs_x[j] + nodesize[j]*cos+π)
    )

  3. Might be possible since Gadfly is a backend of Plots.jl and it is based on Compose.jl, which is what GraphPlot.jl uses. See Make display in the REPL GiovineItalia/Compose.jl#423

hdavid16 added a commit to hdavid16/GraphPlot.jl that referenced this issue Aug 30, 2022
@hdavid16
Copy link
Contributor

hdavid16 commented Sep 27, 2022

@etiennedeg, I thought I'd continue the discussion in #186 (comment) here.

I agree with you on the issue of non-square plots causing problems with the scaling (this still happens when we use triangle arrows instead). However, the arrow head problem persists even with square plots:


JuliaGraphs/GraphPlot.jl#master:

using Compose, Graphs, GraphPlot
Compose.set_default_graphic_size(10cm,10cm)
gplot(path_digraph(10),layout=circular_layout)

Makes the plot:
plot_1

hdavid16/GraphPlot.jl#up:

using Graphs, GaphPlot
gplot(path_digraph(10),layout=circular_layout)

Makes the plot:
plot_5

Observation:
For square plots, the arrow heads look nicer with triangle arrowheads rather than with angled lines. Since you control the corner of the triangles, you can get a cleaner connection to each vertex. So as long as the plot_size is square (the current default in my PR), the issue here is fixed.

@hdavid16
Copy link
Contributor

hdavid16 commented Apr 3, 2023

@willsharpless ,

If you are still working with plotting graphs, I recommend you try GraphMakie, which addresses your issues:

  1. it supports LaTeXStrings without any issue
  2. directed graph arrow heads work (just use arrow_shift=:end)
  3. Since GraphMakie is part of the Makie ecosystem, you get all the great features of using Makie.

PR #186 would fix #2, but I don't know if this will ever be merged into this package.

etiennedeg pushed a commit that referenced this issue May 12, 2024
* Improve Readme and docstring
-distinguish args, kwargs
-add missing kwargs

* fix #166

clarify that Cairo is required to visualize in vscode

* Fix #175 to enable plotting to html

Checking for System OS was outdated

* Document the use of gplothtml in README

* Update open_file

Now matches gadfly.jl (https://github.com/GiovineItalia/Gadfly.jl/blob/master/src/open_file.jl)

* Minor changes:
-allow gplothtml to accept same arguments as gplot
-allow x/y-locs to be of different type (<: Real)

* add TagBot to repo

* Fix #172. set background color (`backgroundc` kwarg):
and minor changes to plots.jl
update README

* add compose child object for background (instead of main level)

* rename to `background_color` + add test

* fixed #149

* support changing plot size (fixes #94, #147)

uses Colorant.set_default_graphic_size

* update default `plot_size` to Compose.jl default

* Fix #107
-Allow add title
-Set title color and size
-Set font family for entire plot
-Remove unneded Compose objects (the ones with `nothing` as the arg)

* scale title margin with title font size

* Fix #160 make self-loop edges curved
behavior is regardless of the linetype

* add padding option for margins
-relevant for plots with curved self-loops and long node labels

* Fix #154

Multiple dispatch was messing up because types were not specified for spring layout and `kws` not preceeded by `;`

* update error msg

* update background rectangle to cover padded area

* add conversion to floats for input locations to avoid error when Ints are passed

* use float instead of Float64

* add tests for layouts

* update compat; remove ColorTypes

* avoid unnecessary allocation if locs are already Floats

Co-authored-by: Simon Schölly <[email protected]>

* avoid allocation in gplot if locs are floats.
fix typo

* update ci.yml to julia 1.6

* bug fix

* add `pad` kwarg to override indvidual paddings

* make lines more robust when self-loops involved

* remove deps to LinAlg and SparseArrays now that not needed for mixed edge styles.

* remove using statements

* Revert "remove deps to LinAlg and SparseArrays now that not needed for mixed edge styles."

This reverts commit c391c55.

* fix bug

when node size uses Width units and padding is used, the arrow ends get thrown off (instead, replace Compose.w with 2.4 (unit box width) to make sure that the right size is used regardless of the padding)

* Change arrows to triangles. Fixes point 2 in #150

* update ref. images in tests for new arrow types

* fixed bug in tests

* -update locs type in gplot and spring_layout
-update default plot_size to square plot

* fix visualization of double sided arcs

* fix bug when edge iterator passed to `graphline`

* fix bug on edgelabels

* closes #95 (add `saveplot`)
also uses Reexport to export Measures

* no need to use Reexport or Measures

* make edge label in center (even for direted)

* .

* add interpolation functions for edge labels

* fix #190

* add note on bezier curve interpolation

---------

Co-authored-by: Simon Schölly <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants