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

Update axis buffer and allow different curvature scalars for each edge #96

Merged
merged 3 commits into from
Feb 17, 2020
Merged

Conversation

JackDevine
Copy link
Member

When you create a custom graph layout, you sometimes want the nodes to fall all have the same x/y coordinate. The old code for the axis buffer didn't behave nicely in this case. Additionally, the old code forced you to have the same axis buffer for each dimension. This is fine for most graph layouts that we generate, but it can be problematic with custom layouts (e.g. flowcharts).

I also added the possibility to have different curvature scalars for each edge, which I think is really useful for flowcharts, but also seems handy in general.

Example

using Plots, GraphRecipes
using LightGraphs

default(size=(400,400))
g = DiGraph(5)
add_edge!(g, 1, 2)
add_edge!(g, 2, 3)
add_edge!(g, 3, 4)
add_edge!(g, 4, 5)
add_edge!(g, 5, 3)
names = [:Thing, :Thingy, :Thinger, :Things, :Stuff]
x = [0,0,0,0,0]
y = [5,4,3,2,1]
curvature_scalar = zeros(length(names),length(names))
curvature_scalar[5,3] = 1.0
graphplot(g, x=x, y=y, names=names, curvature_scalar=curvature_scalar,
          axis_buffer=(1.1,0.2), w=2, color=:black, nodesize=0.3, nodeshape=:circle)

flow_chart
cc: @caseykneale

@caseykneale
Copy link

Awesome! Thanks for working on this Jack! I'm a little new to this collaborative stuff using Github, but let me take a crack at using PR. This will probably help me a lot with https://github.com/caseykneale/Sherlock.jl

@JackDevine JackDevine merged commit cd3ccc8 into JuliaPlots:master Feb 17, 2020
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

Successfully merging this pull request may close these issues.

None yet

2 participants