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

SVG multiline text #336

Merged
merged 1 commit into from
Dec 16, 2018
Merged

SVG multiline text #336

merged 1 commit into from
Dec 16, 2018

Conversation

Mattriks
Copy link
Member

@Mattriks Mattriks commented Dec 15, 2018

This PR:

Example:

using Compose
set_default_graphic_size(10cm, 8cm)

txt = [x*"\n"*y for  x in ["hleft", "hcenter","hright"], 
        y in ["vtop","vcenter","vbottom"] ]
x = repeat(0.1w.*[1,5,9], outer=3)
y = repeat(0.1h.*[1,5,9], inner=3)
xp = repeat([hleft,hcenter,hright], outer=3)
yp = repeat([vtop,vcenter,vbottom], inner=3)

img = compose(context(),
        (context(), circle(x, y, [0.01]), fill("red")),
        text(x, y, txt, xp, yp), fontsize(14pt))

svgtxt1

@codecov-io
Copy link

codecov-io commented Dec 15, 2018

Codecov Report

Merging #336 into master will increase coverage by 0.11%.
The diff coverage is 75%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #336      +/-   ##
==========================================
+ Coverage   37.01%   37.13%   +0.11%     
==========================================
  Files          18       18              
  Lines        3093     3089       -4     
==========================================
+ Hits         1145     1147       +2     
+ Misses       1948     1942       -6
Impacted Files Coverage Δ
src/svg.jl 69.04% <75%> (+0.75%) ⬆️

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 a5f8b81...5285fe7. Read the comment docs.

@bjarthur
Copy link
Member

looks great! looking at the code, it seems that the problem was nesting versus sequential </tspan>s, is that right? which issues will this close?

@Mattriks
Copy link
Member Author

For svg multiline text you also need to know that svg translate is used before svg_newlines, so text position is relative (which simplifies things).

I've also used this PR to produce a Gadfly plot (below), and added a "closes" item to the list in my OP. The svg multiline text issue is also mentioned in #330, but I'm not sure why #330 is still opened?

using DataFrames, Gadfly
set_default_plot_size(5inch,4inch)
palette = ["Midnight\nBlue","Forest\nGreen","Fire\nbrick"]

D = DataFrame(x=["Gold\nrings","Calling\nbirds", "French\nhens","Turtle\ndoves", "Partridges\nin a\nPear tree"],
    y=[5,4,3,2,1], col=["a","a","b","b","c"])
p = plot(D, x=:x, y=:y, color=:col, Geom.bar,
    Guide.colorkey(title="Colors", labels=palette),
    Guide.title("Five essential items\nfor the Yule Season"),
    Scale.color_discrete_manual(replace.(palette, ["\n"=>""])...),
    Guide.ylabel("Number of"),
    Theme(bar_spacing=8pt)
)

# draw(PNG(),p)
draw(SVG(),p)

yuleplot

@bjarthur bjarthur merged commit 8de6805 into GiovineItalia:master Dec 16, 2018
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.

Line break not working in color key title
3 participants