-
-
Notifications
You must be signed in to change notification settings - Fork 28
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
[WIP] Non-Working Example for custom shapes #138
Merged
Merged
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
85bb55f
Non-Working Example for custom shapes
d13992c
Added custom nodeshapes
68aab9c
Added a test for custom shapes and set markershape to :circle
daadad2
Replaced Tabs by spaces and added image for test
e755f04
Changed the way nodeshapes are applied to markershapes and added a
ad70189
Added more descriptive comment for unknown nodeshape errors.
8362ca1
Added different style of generating custom nodeshapes to tests
e286e0a
Removed old test shape
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -141,6 +141,38 @@ function julia_dict_tree() | |
plot(TreePlot(d), method=:tree, fontsize=10, nodeshape=:ellipse, size=(1000, 1000)) | ||
end | ||
|
||
function custom_nodeshapes() | ||
function shapy(x_i,y_i, s) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Inconsistent whitespace conventions. I also like to have no spaces after a comma, however, the convention for the JuliaPlots orginisation is to have whitespace after commas, so |
||
out = Tuple{Float64, Float64}[(-0.5,0),(0,-0.5),(0.5,0),(0,0.5)] | ||
map(out) do t | ||
x = t[1]* s | ||
y = t[2]* s | ||
( | ||
x + x_i, | ||
y + y_i | ||
) | ||
end | ||
end | ||
function shapy_wh(x_i,y_i, h, w) | ||
out = Tuple{Float64, Float64}[(-0.5,0),(0,-0.5),(0.5,0),(0,0.5)] | ||
map(out) do t | ||
x = t[1]* h | ||
y = t[2]* w | ||
( | ||
x + x_i, | ||
y + y_i | ||
) | ||
end | ||
end | ||
Random.seed!(6) | ||
g = rand(5,5) | ||
g[g .> 0.5] .= 0 | ||
for i in 1:5 | ||
g[i,i] = 0 | ||
end | ||
graphplot(g, nodeshape=[:circle, shapy, shapy_wh, :hexagon, shapy]) | ||
end | ||
|
||
function funky_edge_and_marker_args() | ||
Random.seed!(6) | ||
n = 5 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 don't agree with this comment.
The nodeshape is placed into
plotattributes[:markershape]
at line 355:GraphRecipes.jl/src/graphs.jl
Line 355 in 7210d36
However, if
plotattributes[:markershape]
is a function (or a symbol that the backend doesn't recognize), then the backend will fail to create the marker series even though we ultimately create our own marker series later on in the recipe.Ultimately, the whole processing of the attributes that I did from lines 337-356 was a bit of a cludge. I think that the code there is ultimately what has generated the whole confusion.
I would recommend that you add the following to line 357;
The conditional is not strictly necessary, but I think it helps to show that we are only changing the disctionary when
plotattributes[:markershape]
is something that the backend does not recognize.Feel free to alter the comment a little to make it easier to understand/add your own flare.
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 still don't agree with this comment. In particular, I don't understand the phrase "nodeshapes not compatible with the shapes of plotting". The phrase "shapes of plotting" does have a very sentimental/artistic flare, however, is not really specific enough for this context. Rather than "shapes of plotting", I think that you should say "symbols that the backend will recognize as a valid value of plotattributes[:markershape]".
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.
My main intention with the comment was to keep the knowledge why this special case had to be introduced. Your code and comment capture that much better. I just added a line to make clarify that the lines where introduced to allow custom nodeshapes.
I changed the code to match yours, the tests then suggested some further changes.