juliaplots / cairomakie.jl Goto Github PK
View Code? Open in Web Editor NEWCairo backend for Makie
License: Other
Cairo backend for Makie
License: Other
If text is drawn with space=:data
into an axis with yreversed
set true, then the text is drawn upside down. There appears to be no way around this as there is no option to apply inversion to the text alone.
While I understand this is technically correct in computer graphics, as the text is being drawn in an inverted coordinate space, it does not seem to be be appropriate in plotting. While the direction of the axis may change the way in which data representations are arranged, it should not change those representations.
This should close and lock
Moved to MakieOrg/Makie.jl#882
The activate!
functions defined here errors with:
julia> CairoMakie.activate!()
ERROR: MethodError: no method matching CairoMakie.CairoBackend()
Closest candidates are:
CairoMakie.CairoBackend(::CairoMakie.RenderType, ::String) at /home/pietro/.julia/packages/CairoMakie/j1qYD/src/CairoMakie.jl:15
CairoMakie.CairoBackend(::String) at /home/pietro/.julia/packages/CairoMakie/j1qYD/src/CairoMakie.jl:26
CairoMakie.CairoBackend(::Any, ::Any) at /home/pietro/.julia/packages/CairoMakie/j1qYD/src/CairoMakie.jl:15
Stacktrace:
[1] activate!(::Bool) at /home/pietro/.julia/packages/CairoMakie/j1qYD/src/CairoMakie.jl:510 (repeats 2 times)
[2] top-level scope at none:0
would help the italics situation, which I need to plot stuff for papers
This is using PR #44.
The position of a marker should be anchored on its center, not its edges.
In the following MWE you'll notice that the red marker's location is not centered on (0, 0)
:
scene = scatter(Tuple.(eachrow(rand(3,2))));
scatter!([0], [0], color = :red);
I came across this issue while trying to use this package to save some heat maps as PDFs. Basically, CairoMakie seems to be shifting the heat maps slightly compared to using GLMakie + FileIO to save the same plot
using MakieLayout, CairoMakie, AbstractPlotting, GLMakie, FileIO
AbstractPlotting.inline!(false)
scene = Scene(resolution=(800,600), camera=campixel!);
layout = GridLayout(scene, alignmode=Outside(20));
la = layout[1,1] = LAxis(scene)
heatmap!(la, rand(100,100))
la.title = "GL"
AbstractPlotting.current_backend[] = GLMakie.GLBackend()
display(scene)
FileIO.save("imgtestgl.png",scene)
tmp = "imgtestcairo.png"
AbstractPlotting.current_backend[] = CairoMakie.CairoBackend(tmp)
la.title = "Cairo"
scene
The color interpretation in CairoMakie is wrong, compared to GL makie and Plots:
MWE:
a = 0:0.1:Ο/2
x = cos.(a)
y = [1.0 for xx in x]
z = sin.(a)
using Plots
Plots.scatter(x, y, z, marker_z = a )
using GLMakie
GLMakie.activate!()
fig = meshscatter(x, y, z, markersize = 0.05, color=a)
using CairoMakie
CairoMakie.activate!()
fig = meshscatter(x, y, z, markersize = 0.05, color=a)
Let's test this out. This issue should immediately be auto closed.
For proper UTF-16 support, it looks like we can't use Cairo's text API - we may have to switch to glyphs.
CairoMakie.jl/src/CairoMakie.jl
Lines 211 to 228 in 2c98305
Could we batch the face creation and then draw everything afterwards?
This issue is used to trigger TagBot; feel free to unsubscribe.
If you haven't already, you should update your TagBot.yml
to include issue comment triggers.
Please see this post on Discourse for instructions and more details.
If you'd like for me to do this for you, comment TagBot fix
on this issue.
I'll open a PR within a few hours, please be patient!
I get an error running the tests, which mentions that Figure is not defined and points to line 6 of runtests.jl, see the log below.
I have installed CairoMakie, GLMakie and GeoMakie.
Output of versioninfo()
:
julia> versioninfo()
Julia Version 1.6.1
Commit 6aaedecc44* (2021-04-23 05:59 UTC)
Platform Info:
OS: Linux (x86_64-pc-linux-gnu)
CPU: Intel(R) Core(TM) i7-8705G CPU @ 3.10GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-11.1.0 (ORCJIT, skylake)
(@v1.6) pkg> test CairoMakie
Testing CairoMakie
Status `/tmp/jl_imfO4T/Project.toml`
[537997a7] AbstractPlotting v0.13.11
[159f3aea] Cairo v1.0.5
[13f3f980] CairoMakie v0.3.19
[5ae59095] Colors v0.12.8
[7a1cc6ca] FFTW v1.4.1
[5789e2e9] FileIO v1.9.0
[b38be410] FreeType v3.0.1
[5c1252a2] GeometryBasics v0.3.10
[90137ffa] StaticArrays v1.2.1
[37e2e46d] LinearAlgebra `@stdlib/LinearAlgebra`
[44cfe95a] Pkg `@stdlib/Pkg`
[8dfed614] Test `@stdlib/Test`
Status `/tmp/jl_imfO4T/Manifest.toml`
[621f4979] AbstractFFTs v1.0.1
[537997a7] AbstractPlotting v0.13.11
[79e6a3ab] Adapt v3.3.0
[27a7e980] Animations v0.4.1
[4fba245c] ArrayInterface v3.1.15
[13072b0f] AxisAlgorithms v1.0.0
[fa961155] CEnum v0.4.1
[159f3aea] Cairo v1.0.5
[13f3f980] CairoMakie v0.3.19
[d360d2e6] ChainRulesCore v0.9.44
[a2cac450] ColorBrewer v0.4.0
[35d6a980] ColorSchemes v3.12.1
[3da002f7] ColorTypes v0.10.12
[c3611d14] ColorVectorSpace v0.8.7
[5ae59095] Colors v0.12.8
[34da2185] Compat v3.30.0
[d38c429a] Contour v0.5.7
[9a962f9c] DataAPI v1.6.0
[864edb3b] DataStructures v0.18.9
[e2d170a0] DataValueInterfaces v1.0.0
[31c24e10] Distributions v0.24.18
[ffbed154] DocStringExtensions v0.8.4
[da5c29d0] EllipsisNotation v1.1.0
[c87230d0] FFMPEG v0.4.0
[7a1cc6ca] FFTW v1.4.1
[5789e2e9] FileIO v1.9.0
[1a297f60] FillArrays v0.11.7
[53c48c17] FixedPointNumbers v0.8.4
[59287772] Formatting v0.4.2
[b38be410] FreeType v3.0.1
[663a7486] FreeTypeAbstraction v0.8.4
[5c1252a2] GeometryBasics v0.3.10
[a2bd30eb] Graphics v1.1.0
[3955a311] GridLayoutBase v0.4.1
[42e2da0e] Grisu v1.0.2
[615f187c] IfElse v0.1.0
[a09fc81d] ImageCore v0.8.22
[82e4d734] ImageIO v0.3.1
[9b13fd28] IndirectArrays v0.5.1
[a98d9a8b] Interpolations v0.13.2
[8197267c] IntervalSets v0.5.3
[f1662d9f] Isoband v0.1.1
[c8e1da08] IterTools v1.3.0
[82899510] IteratorInterfaceExtensions v1.0.0
[692b3bcd] JLLWrappers v1.3.0
[682c06a0] JSON v0.21.1
[5ab0869b] KernelDensity v0.6.3
[2ab3a3ac] LogExpFunctions v0.2.4
[dbb5928d] MappedArrays v0.4.0
[7eb4fadd] Match v1.1.0
[e1d29d7a] Missings v1.0.0
[e94cdb99] MosaicViews v0.3.3
[77ba4419] NaNMath v0.3.5
[510215fc] Observables v0.3.3
[6fe1bfb0] OffsetArrays v1.9.0
[bac558e1] OrderedCollections v1.4.1
[90014a1f] PDMats v0.11.0
[f57f5aa1] PNGFiles v0.3.7
[19eb6ba3] Packing v0.4.1
[5432bcbf] PaddedViews v0.5.8
[69de0a69] Parsers v1.1.0
[995b91a9] PlotUtils v1.0.10
[647866c9] PolygonOps v0.1.1
[21216c6a] Preferences v1.2.2
[1fd47b50] QuadGK v2.4.1
[c84ed2f1] Ratios v0.4.0
[189a3867] Reexport v0.2.0
[ae029012] Requires v1.1.3
[79098fc4] Rmath v0.7.0
[992d4aef] Showoff v0.3.2
[73760f76] SignedDistanceFields v0.4.0
[a2af1166] SortingAlgorithms v1.0.0
[276daf66] SpecialFunctions v1.4.2
[cae243ae] StackViews v0.1.1
[aedffcd0] Static v0.2.4
[90137ffa] StaticArrays v1.2.1
[82ae8749] StatsAPI v1.0.0
[2913bbd2] StatsBase v0.33.8
[4c63d2b9] StatsFuns v0.9.8
[09ab397b] StructArrays v0.4.2
[3783bdb8] TableTraits v1.0.1
[bd369af6] Tables v1.4.2
[1cfade01] UnicodeFun v0.4.1
[efce3f68] WoodburyMatrices v0.5.3
[6e34b625] Bzip2_jll v1.0.6+5
[83423d85] Cairo_jll v1.16.0+6
[5ae413db] EarCut_jll v2.1.5+1
[2e619515] Expat_jll v2.2.10+0
[b22a6f82] FFMPEG_jll v4.3.1+4
[f5851436] FFTW_jll v3.3.9+7
[a3f928ae] Fontconfig_jll v2.13.1+14
[d7e528f0] FreeType2_jll v2.10.1+5
[559328eb] FriBidi_jll v1.0.10+0
[78b55507] Gettext_jll v0.20.1+7
[7746bdde] Glib_jll v2.59.0+4
[3b182d85] Graphite2_jll v1.3.14+0
[2e76f6c2] HarfBuzz_jll v2.6.1+10
[a51ab1cf] ICU_jll v67.1.0+3
[1d5cc7b8] IntelOpenMP_jll v2018.0.3+2
[c1c5ebd0] LAME_jll v3.100.0+3
[dd4b983a] LZO_jll v2.10.1+0
[dd192d2f] LibVPX_jll v1.9.0+1
[e9f186c6] Libffi_jll v3.2.2+0
[d4300ac3] Libgcrypt_jll v1.8.7+0
[7add5ba3] Libgpg_error_jll v1.42.0+0
[94ce4f54] Libiconv_jll v1.16.1+0
[4b2f31a3] Libmount_jll v2.35.0+0
[38a345b3] Libuuid_jll v2.36.0+0
[856f044c] MKL_jll v2021.1.1+1
[e7412a2a] Ogg_jll v1.3.4+2
[458c3c95] OpenSSL_jll v1.1.1+6
[efe28fd5] OpenSpecFun_jll v0.5.4+0
[91d4177d] Opus_jll v1.3.1+3
[2f80f16e] PCRE_jll v8.44.0+0
[36c8627f] Pango_jll v1.42.4+10
[30392449] Pixman_jll v0.40.1+0
[f50d1b31] Rmath_jll v0.3.0+0
[02c8fc9c] XML2_jll v2.9.12+0
[aed1982a] XSLT_jll v1.1.34+0
[4f6342f7] Xorg_libX11_jll v1.6.9+4
[0c0b7dd1] Xorg_libXau_jll v1.0.9+4
[a3789734] Xorg_libXdmcp_jll v1.1.3+4
[1082639a] Xorg_libXext_jll v1.3.4+4
[ea2f1a96] Xorg_libXrender_jll v0.9.10+4
[14d82f49] Xorg_libpthread_stubs_jll v0.1.0+3
[c7cfdc94] Xorg_libxcb_jll v1.13.0+3
[c5fb5394] Xorg_xtrans_jll v1.4.0+3
[9a68df92] isoband_jll v0.2.2+0
[0ac62f75] libass_jll v0.14.0+4
[f638f0a6] libfdk_aac_jll v0.1.6+4
[b53b4c65] libpng_jll v1.6.38+0
[f27f6e37] libvorbis_jll v1.3.6+6
[1270edf5] x264_jll v2020.7.14+2
[dfaa095f] x265_jll v3.0.0+3
[0dad84c5] ArgTools `@stdlib/ArgTools`
[56f22d72] Artifacts `@stdlib/Artifacts`
[2a0f44e3] Base64 `@stdlib/Base64`
[ade2ca70] Dates `@stdlib/Dates`
[8bb1440f] DelimitedFiles `@stdlib/DelimitedFiles`
[8ba89e20] Distributed `@stdlib/Distributed`
[f43a241f] Downloads `@stdlib/Downloads`
[b77e0a4c] InteractiveUtils `@stdlib/InteractiveUtils`
[4af54fe1] LazyArtifacts `@stdlib/LazyArtifacts`
[b27032c2] LibCURL `@stdlib/LibCURL`
[76f85450] LibGit2 `@stdlib/LibGit2`
[8f399da3] Libdl `@stdlib/Libdl`
[37e2e46d] LinearAlgebra `@stdlib/LinearAlgebra`
[56ddb016] Logging `@stdlib/Logging`
[d6f4376e] Markdown `@stdlib/Markdown`
[a63ad114] Mmap `@stdlib/Mmap`
[ca575930] NetworkOptions `@stdlib/NetworkOptions`
[44cfe95a] Pkg `@stdlib/Pkg`
[de0858da] Printf `@stdlib/Printf`
[3fa0cd96] REPL `@stdlib/REPL`
[9a3f8284] Random `@stdlib/Random`
[ea8e919c] SHA `@stdlib/SHA`
[9e88b42a] Serialization `@stdlib/Serialization`
[1a1011a3] SharedArrays `@stdlib/SharedArrays`
[6462fe0b] Sockets `@stdlib/Sockets`
[2f01184e] SparseArrays `@stdlib/SparseArrays`
[10745b16] Statistics `@stdlib/Statistics`
[4607b0f0] SuiteSparse `@stdlib/SuiteSparse`
[fa267f1f] TOML `@stdlib/TOML`
[a4e569a6] Tar `@stdlib/Tar`
[8dfed614] Test `@stdlib/Test`
[cf7118a7] UUIDs `@stdlib/UUIDs`
[4ec0a83e] Unicode `@stdlib/Unicode`
[e66e0078] CompilerSupportLibraries_jll `@stdlib/CompilerSupportLibraries_jll`
[deac9b47] LibCURL_jll `@stdlib/LibCURL_jll`
[29816b5a] LibSSH2_jll `@stdlib/LibSSH2_jll`
[c8ffd9c3] MbedTLS_jll `@stdlib/MbedTLS_jll`
[14a3606d] MozillaCACerts_jll `@stdlib/MozillaCACerts_jll`
[83775a58] Zlib_jll `@stdlib/Zlib_jll`
[8e850ede] nghttp2_jll `@stdlib/nghttp2_jll`
[3f19e933] p7zip_jll `@stdlib/p7zip_jll`
Testing Running tests...
Runs without error: Error During Test at /home/admin/.julia/packages/CairoMakie/P8WWZ/test/runtests.jl:5
Got exception outside of a @test
UndefVarError: Figure not defined
Stacktrace:
[1] macro expansion
@ ~/.julia/packages/CairoMakie/P8WWZ/test/runtests.jl:6 [inlined]
[2] macro expansion
@ /build/julia/src/julia-1.6.1/usr/share/julia/stdlib/v1.6/Test/src/Test.jl:1151 [inlined]
[3] top-level scope
@ ~/.julia/packages/CairoMakie/P8WWZ/test/runtests.jl:6
[4] include(fname::String)
@ Base.MainInclude ./client.jl:444
[5] top-level scope
@ none:6
Test Summary: | Error Total
Runs without error | 1 1
ERROR: LoadError: Some tests did not pass: 0 passed, 0 failed, 1 errored, 0 broken.
in expression starting at /home/admin/.julia/packages/CairoMakie/P8WWZ/test/runtests.jl:5
ERROR: Package CairoMakie errored during testing
Heatmaps in CairoMakie 'tile', like this:
using AbstractPlotting, CairoMakie
AbstractPlotting.current_backend[] = CairoMakie.CairoBackend("./temp.svg")
heatmap(rand(10, 10))
yields this: (sorry for the weird border, it's a screenshot)
and switching to PNG backend yields this:
This is the function that (I think) draws a heatmap in CairoMakie.
CairoMakie.jl/src/CairoMakie.jl
Lines 239 to 258 in cae15f2
cc: @cormullion - would you mind taking a look?
aog = data(plotdata) * (visual(Scatter, strokewidth=0, markersize=4) + visual(LineSegments)) * mapping(:x, :y, color=:c, layout_y=:ly)
scene, layout = layoutscene(resolution=(800,1000))
AlgebraOfGraphics.layoutplot!(scene, layout, aog)
save(filename, scene)
ERROR: LoadError: AssertionError: iseven(length(positions))
Stacktrace:
[1] draw_single(::Combined{AbstractPlotting.linesegments,Tuple{Array{Point{2,Float32},1}}}, ::Cairo.CairoContext, ::Array{Vec{2,Float32},1}) at /home/user/.julia/packages/CairoMakie/3xFKY/src/primitives.jl:91
[2] draw_atomic(::Scene, ::CairoMakie.CairoScreen{Cairo.CairoSurfaceBase{UInt32}}, ::Combined{AbstractPlotting.linesegments,Tuple{Array{Point{2,Float32},1}}}) at /home/user/.julia/packages/CairoMakie/3xFKY/src/primitives.jl:69
[3] draw_plot(::Scene, ::CairoMakie.CairoScreen{Cairo.CairoSurfaceBase{UInt32}}, ::Combined{AbstractPlotting.linesegments,Tuple{Array{Point{2,Float32},1}}}) at /home/user/.julia/packages/CairoMakie/3xFKY/src/infrastructure.jl:227
[4] cairo_draw(::CairoMakie.CairoScreen{Cairo.CairoSurfaceBase{UInt32}}, ::Scene) at /home/user/.julia/packages/CairoMakie/3xFKY/src/infrastructure.jl:161
[5] backend_show(::CairoMakie.CairoBackend, ::IOContext{IOStream}, ::MIME{Symbol("image/png")}, ::Scene) at /home/user/.julia/packages/CairoMakie/3xFKY/src/infrastructure.jl:307
[6] show(::IOContext{IOStream}, ::MIME{Symbol("image/png")}, ::Scene) at /home/user/.julia/packages/AbstractPlotting/3blWv/src/display.jl:130
[7] (::AbstractPlotting.var"#779#780"{Float64,Float64,Scene,DataType})(::IOStream) at /home/user/.julia/packages/AbstractPlotting/3blWv/src/display.jl:251
[8] open(::AbstractPlotting.var"#779#780"{Float64,Float64,Scene,DataType}, ::String, ::Vararg{String,N} where N; kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at ./io.jl:325
[9] open(::Function, ::String, ::String) at /nix/store/lb43a78rgdbpfa1
...
The pdf created for the following heatmap is 15.7MB when using CairoMakie v0.5.9 and only 335kB when using CairoMakie v0.5.7.
f = Figure()
Axis(f[1, 1])
xs = LinRange(0, 10, 1000)
ys = LinRange(0, 15, 1000)
zs = [cos(x) * sin(y) for x in xs, y in ys]
heatmap!(xs, ys, zs)
save("fig.pdf", f)
Characters which GLMakie renders (π£
-\itv
) cannot be rendered by CairoMakie.
β Warning: `a::StaticArray + b::Number` is deprecated, use `a .+ b` instead.
β caller = project_position(::Scene, ::Point{2,Float32}, ::StaticArrays.SArray{Tuple{4,4},Float32,2,16}) at CairoMakie.jl:74
β @ CairoMakie ~/.julia/dev/CairoMakie/src/CairoMakie.jl:74
Iβve been trying to make heatmaps using colormaps that go from transparent to either white or black.
The interpolation works as expected for black but it looks terrible for white.
Hereβs some sample code with the result:
using CairoMakie, Plots.Colors
xs = LinRange(0, 10, 100)
ys = LinRange(0,10, 100)
zs = [x+im*y for x in xs, y in ys]
rings = abs.(zs) .% 3
fig = Figure();
ax1 = fig[1, 1] = Axis( fig, backgroundcolor="blue");
ax2 = fig[2, 1] = Axis( fig, backgroundcolor="blue");
cmblack = cgrad(range(HSLA(0,0,0,0), stop=HSLA(0,0,0,1), length=100));
CairoMakie.heatmap!(ax1, xs, ys, rings, colormap=cmblack, interpolate=true);
cmwhite = cgrad(range(HSLA(0,0,1,0), stop=HSLA(0,0,1,1), length=100));
CairoMakie.heatmap!(ax2, xs, ys, rings, colormap=cmwhite, interpolate=true);
fig
Screenshot from Juno:
Saved PNG:
I noticed the comment "Set filter doesn't work!?" in src/primitives.jl, so maybe this is a known issue? I'll try to investigate more in case I can help...
When plotting successive figures with the SVG backend, the previous figures linger and contaminate the new figure. This is visible in a recent docs preview in MixedModelsMakie. The first plot renders correctly, but the second and third plots have clear problems with overprinting in the y-axis labels. Likewise, the final plot, which is completely distinct clearly has some overplotted axis labels from the first three plots.
cc @dmbates
Just to make sure it works.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.