Skip to content

Support vector of colors (barplot, boxplot) #227

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

Merged
merged 5 commits into from
Feb 12, 2022

Conversation

t-bltg
Copy link
Member

@t-bltg t-bltg commented Feb 11, 2022

@codecov-commenter
Copy link

codecov-commenter commented Feb 11, 2022

Codecov Report

Merging #227 (73e9a69) into master (1237155) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #227   +/-   ##
=======================================
  Coverage   99.93%   99.93%           
=======================================
  Files          28       28           
  Lines        1450     1467   +17     
=======================================
+ Hits         1449     1466   +17     
  Misses          1        1           
Impacted Files Coverage Δ
src/interface/boxplot.jl 100.00% <ø> (ø)
src/interface/densityplot.jl 100.00% <ø> (ø)
src/interface/heatmap.jl 100.00% <ø> (ø)
src/interface/histogram.jl 100.00% <ø> (ø)
src/interface/lineplot.jl 100.00% <ø> (ø)
src/interface/scatterplot.jl 100.00% <ø> (ø)
src/interface/spy.jl 100.00% <ø> (ø)
src/interface/stairs.jl 100.00% <ø> (ø)
src/graphics.jl 100.00% <100.00%> (ø)
src/graphics/bargraphics.jl 100.00% <100.00%> (ø)
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1237155...73e9a69. Read the comment docs.

@t-bltg t-bltg requested a review from johnnychen94 February 11, 2022 18:07
@stelmo
Copy link

stelmo commented Feb 11, 2022

This is awesome, thanks 😃! Would it be possible to add the ylim (or would it be xlim) kwarg to barplot too?

@t-bltg
Copy link
Member Author

t-bltg commented Feb 11, 2022

If the plots with distinct colors are combined in a single one, they should already be aligned, no ?

Did you try using the width keyword ?

Have a look at:

help?> barplot
[...]
    •  margin::Int = 3 : number of empty characters to the left of the whole plot.
    •  padding::Int = 1 : left and right space between the labels and the canvas.
    •  width::Int = 40 : number of characters per canvas row.
[...]

@stelmo
Copy link

stelmo commented Feb 11, 2022

Yep, totally, if the plotted series are in the same graph then they should be to the same scale. The x/ylim thing would be more useful if opted to keep the plots separate, but wanted to maintain a sense of scale between them.

@t-bltg
Copy link
Member Author

t-bltg commented Feb 11, 2022

I think the keyword width is exactly what you need.

@stelmo
Copy link

stelmo commented Feb 12, 2022

One last question, do these changes allow one to add a legend for bar plots, to indicate what each color means?

@t-bltg
Copy link
Member Author

t-bltg commented Feb 12, 2022

I think the keyword width is exactly what you need.

I was wrong, I've added a new keyword maximum to reflect that.

julia> using UnicodePlots
julia> barplot(["1", "2", "3"], [1, 2, 3], maximum = 10)
     ┌                                        ┐ 
   1 ┤■■■■ 1                                    
   2 ┤■■■■■■■ 2                                 
   3 ┤■■■■■■■■■■■ 3                             
     └                                        ┘ 
julia> barplot(["1", "2", "3", "4"], [1, 2, 3, 10], maximum = 10)
     ┌                                        ┐ 
   1 ┤■■■■ 1                                    
   2 ┤■■■■■■■ 2                                 
   3 ┤■■■■■■■■■■■ 3                             
   4 ┤■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 10   
     └                                        ┘

One last question, do these changes allow one to add a legend for bar plots, to indicate what each color means?

I've added support for name (which is standard across UnicodePlots), it should be colored in your REPL:

julia> p = barplot(["1", "2", "3"], [1, 2, 3], color = :blue, name = "1ˢᵗ series", maximum = 10)
julia> barplot!(p, ["4", "5", "6"], [6, 1, 10], color = :red, name = "2ⁿᵈ series")
     ┌                                        ┐           
   1 ┤■■■■ 1                                    1ˢᵗ series
   2 ┤■■■■■■■ 2                                 2ⁿᵈ series
   3 ┤■■■■■■■■■■■ 3                                       
   4 ┤■■■■■■■■■■■■■■■■■■■■■■ 6                            
   5 ┤■■■■ 1                                              
   6 ┤■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 10             
     └                                        ┘    

@stelmo
Copy link

stelmo commented Feb 12, 2022

Thank you very much, this looks awesome! I really appreciate all the effort you put into this request :) Once the package I am developing to visualize some flux measurements at the repl for COBREXA.jl is done, I will ping you so that you can see what came of it :) Once again, thank you very much!!!

@t-bltg t-bltg merged commit bfb9232 into JuliaPlots:master Feb 12, 2022
@t-bltg t-bltg deleted the bar_cols branch February 12, 2022 19:52
@t-bltg
Copy link
Member Author

t-bltg commented Feb 12, 2022

I will release a new version when #224 is merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants