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

Gadfly scaling of figures got very much strange after the latest updates #1587

Open
montyvesselinov opened this issue May 29, 2022 · 36 comments

Comments

@montyvesselinov
Copy link

montyvesselinov commented May 29, 2022

(@v1.7) pkg> st Gadfly
Status C:\Users\monty\.julia\environments\v1.7\Project.toml
[c91e804a] Gadfly v1.3.4

(@v1.7) pkg> st Compose
Status C:\Users\monty\.julia\environments\v1.7\Project.toml
[a81c6b42] Compose v0.9.3

The following produces very weird ouput:

Gadfly.draw(Gadfly.PNG("a.png", 3Gadfly.inch, 3Gadfly.inch), Gadfly.plot(x=rand(10), y=rand(10), Gadfly.Scale.y_sqrt, Gadfly.Geom.point, Gadfly.Guide.xlabel("Time"), Gadfly.Guide.ylabel("Response"), Gadfly.Guide.title("Test")))

a

@montyvesselinov
Copy link
Author

Any suggestions how to fix this?! It is very weird.

@montyvesselinov
Copy link
Author

@bjarthur can you help?! thank you!

@bjarthur
Copy link
Member

not a problem for me:

a

try checking out the master branch of Gadfly and Compose with ]dev Gadfly Compose

@nathanrboyer
Copy link

Same issue I am having in #1572 and here.

@montyvesselinov
Copy link
Author

@bjarthur are there any updates on this. Clearly, Fontconfig causes this problem. Maybe it is only related to Windows machines but it is very annoying and causes many issues. Thank you!

@montyvesselinov
Copy link
Author

@bjarthur

things get even worse if manual key is implemented:

Gadfly.draw(Gadfly.PNG("a.png", 3Gadfly.inch, 3Gadfly.inch), Gadfly.plot(x=rand(10), y=rand(10), Gadfly.Scale.y_sqrt, Gadfly.Geom.point, Gadfly.Guide.xlabel(""), Gadfly.Guide.ylabel(""), Gadfly.Guide.title("Test"), Gadfly.Guide.manual_color_key("", ["Truth", "Prediction"], ["red", "blue"]; shape=[Gadfly.Shape.circle, Gadfly.Shape.hline])))

a

@montyvesselinov
Copy link
Author

@bjarthur these issues are extremely annoying and create a lof of plotting issues.

@montyvesselinov
Copy link
Author

@bjarthur dev versions also do not work and produce the same issues.

@bjarthur
Copy link
Member

sorry, but how can i help if i can't reproduce? the code is open source. please have a look.

@montyvesselinov
Copy link
Author

do you have any suggestions where to start? Are there any known issues with Fontconfig for Windows?

@bjarthur
Copy link
Member

i would guess the bug is in Compose/src/pango.jl somewhere.

@montyvesselinov
Copy link
Author

@bjarthur

here is another crazy result:

Gadfly.draw(Gadfly.PNG("a.png", 3Gadfly.inch, 3Gadfly.inch), Gadfly.plot(x=1:5000, y=1:5000))

a

@montyvesselinov
Copy link
Author

I guess there is an issue with font rendering. The code incorrectly predicts the size of the axis titles and labels. It is especially pronounced if superscripts are invoked.

@montyvesselinov
Copy link
Author

Where in the code the size of generated labels is processed?

Do you have tests in Compose about the size of generated text?

@montyvesselinov
Copy link
Author

Compose tests fail on windows:

               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.7.3 (2022-05-06)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

(@v1.7) pkg> test Compose
     Testing Compose
      Status `C:\Users\monty\AppData\Local\Temp\jl_fQZIAA\Project.toml`
  [159f3aea] Cairo v1.0.5
  [5ae59095] Colors v0.12.8
  [a81c6b42] Compose v0.9.3
  [864edb3b] DataStructures v0.18.13
  [8f5d6c58] EzXML v1.1.0
  [186bb1d3] Fontconfig v0.4.0
  [c8e1da08] IterTools v1.4.0
  [682c06a0] JSON v0.21.3
  [442fdcdd] Measures v0.3.1
  [ae029012] Requires v1.3.0
  [2a0f44e3] Base64 `@stdlib/Base64`
  [ade2ca70] Dates `@stdlib/Dates`
  [37e2e46d] LinearAlgebra `@stdlib/LinearAlgebra`
  [de0858da] Printf `@stdlib/Printf`
  [9a3f8284] Random `@stdlib/Random`
  [10745b16] Statistics `@stdlib/Statistics`
  [8dfed614] Test `@stdlib/Test`
  [cf7118a7] UUIDs `@stdlib/UUIDs`
      Status `C:\Users\monty\AppData\Local\Temp\jl_fQZIAA\Manifest.toml`
  [159f3aea] Cairo v1.0.5
  [3da002f7] ColorTypes v0.11.4
  [5ae59095] Colors v0.12.8
  [34da2185] Compat v3.45.0
  [a81c6b42] Compose v0.9.3
  [864edb3b] DataStructures v0.18.13
  [8f5d6c58] EzXML v1.1.0
  [53c48c17] FixedPointNumbers v0.8.4
  [186bb1d3] Fontconfig v0.4.0
  [a2bd30eb] Graphics v1.1.2
  [c8e1da08] IterTools v1.4.0
  [692b3bcd] JLLWrappers v1.4.1
  [682c06a0] JSON v0.21.3
  [442fdcdd] Measures v0.3.1
  [77ba4419] NaNMath v0.3.7
  [bac558e1] OrderedCollections v1.4.1
  [69de0a69] Parsers v2.3.2
  [21216c6a] Preferences v1.3.0
  [189a3867] Reexport v1.2.2
  [ae029012] Requires v1.3.0
  [6e34b625] Bzip2_jll v1.0.8+0
  [83423d85] Cairo_jll v1.16.1+1
  [2e619515] Expat_jll v2.4.8+0
  [a3f928ae] Fontconfig_jll v2.13.93+0
  [d7e528f0] FreeType2_jll v2.10.4+0
  [559328eb] FriBidi_jll v1.0.10+0
  [78b55507] Gettext_jll v0.21.0+0
  [7746bdde] Glib_jll v2.68.3+2
  [3b182d85] Graphite2_jll v1.3.14+0
  [2e76f6c2] HarfBuzz_jll v2.8.1+1
  [dd4b983a] LZO_jll v2.10.1+0
  [e9f186c6] Libffi_jll v3.2.2+1
  [d4300ac3] Libgcrypt_jll v1.8.7+0
  [7add5ba3] Libgpg_error_jll v1.42.0+0
  [94ce4f54] Libiconv_jll v1.16.1+1
  [4b2f31a3] Libmount_jll v2.35.0+0
  [38a345b3] Libuuid_jll v2.36.0+0
  [2f80f16e] PCRE_jll v8.44.0+0
  [36c8627f] Pango_jll v1.50.3+0
  [30392449] Pixman_jll v0.40.1+0
  [02c8fc9c] XML2_jll v2.9.14+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
  [b53b4c65] libpng_jll v1.6.38+0
  [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`
  [7b1f6079] FileWatching `@stdlib/FileWatching`
  [b77e0a4c] InteractiveUtils `@stdlib/InteractiveUtils`
  [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`
  [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`
  [4536629a] OpenBLAS_jll `@stdlib/OpenBLAS_jll`
  [83775a58] Zlib_jll `@stdlib/Zlib_jll`
  [8e850b90] libblastrampoline_jll `@stdlib/libblastrampoline_jll`
  [8e850ede] nghttp2_jll `@stdlib/nghttp2_jll`
  [3f19e933] p7zip_jll `@stdlib/p7zip_jll`
     Testing Running tests...
Test Summary:        | Pass  Total
missing cairo errors |    6      6
table: Test Failed at C:\Users\monty\.julia\packages\Compose\h4MDD\test\misc.jl:48
  Expression: replace(str, " " => "") == "Compose.Table($(Vector{Context})[[]],3:3,1:1,nothing,nothing,1.6,Any[],nothing,0,false,false)"
   Evaluated: "Compose.Table(Vector{Context}[[];;],3:3,1:1,nothing,nothing,1.6,Any[],nothing,0,false,false)" == "Compose.Table(Vector{Context}[[]],3:3,1:1,nothing,nothing,1.6,Any[],nothing,0,false,false)"
Stacktrace:
 [1] macro expansion
   @ C:\Users\monty\AppData\Local\Programs\Julia-1.7.3\share\julia\stdlib\v1.7\Test\src\Test.jl:445 [inlined]
 [2] macro expansion
   @ C:\Users\monty\.julia\packages\Compose\h4MDD\test\misc.jl:48 [inlined]
 [3] macro expansion
   @ C:\Users\monty\AppData\Local\Programs\Julia-1.7.3\share\julia\stdlib\v1.7\Test\src\Test.jl:1283 [inlined]
 [4] macro expansion
   @ C:\Users\monty\.julia\packages\Compose\h4MDD\test\misc.jl:37 [inlined]
 [5] macro expansion
   @ C:\Users\monty\AppData\Local\Programs\Julia-1.7.3\share\julia\stdlib\v1.7\Test\src\Test.jl:1283 [inlined]
 [6] top-level scope
   @ C:\Users\monty\.julia\packages\Compose\h4MDD\test\misc.jl:20
Test Summary: | Pass  Fail  Total
printing      |    3     1      4
  context     |    2            2
  table       |    1     1      2
ERROR: LoadError: Some tests did not pass: 3 passed, 1 failed, 0 errored, 0 broken.
in expression starting at C:\Users\monty\.julia\packages\Compose\h4MDD\test\misc.jl:19
in expression starting at C:\Users\monty\.julia\packages\Compose\h4MDD\test\runtests.jl:3
ERROR: Package Compose errored during testing

@bjarthur
Copy link
Member

bjarthur commented Jul 4, 2022

what exactly is crazy? your post is blank. i see:

Gadfly.plot(x=1:5000, y=1:5000)

Screen Shot 2022-07-04 at 4 54 52 PM

Gadfly.plot(x=1:5000, y=1:5000, Theme(highlight_width=0mm))

Screen Shot 2022-07-04 at 4 54 59 PM

in the former, the blue interior is being hidden by the white outlines.

@bjarthur
Copy link
Member

bjarthur commented Jul 4, 2022

Compose tests should pass once JuliaRegistries/General#63655 is merged. this was fixed awhile back. when reporting errors, please first checkout the master branch to confirm they still exist.

@bjarthur
Copy link
Member

bjarthur commented Jul 4, 2022

the Compose.jl code i linked above defines max_text_extents. a quick search in Gadfly shows it is used throughout guide.jl.
e.g. https://github.com/GiovineItalia/Gadfly.jl/blob/master/src/guide.jl#L872-L874

@Mattriks
Copy link
Member

Mattriks commented Jul 4, 2022

JuliaGraphics/Cairo.jl#349: is this related?

@montyvesselinov
Copy link
Author

@Mattriks JuliaGraphics/Cairo.jl#349 might be related. But this is potentially not the only problem. Definitely, there are issues with Gadfly/Compose when the font sizes are less than 1 pt. I have observed this as well in the past.

@montyvesselinov
Copy link
Author

Gadfly.plot(x=1:5000, y=1:5000)

produces

image

The svg file is attached

plot_1

as you can see the axis labeling is crazy. the location of the axis titles are crazy.

@montyvesselinov
Copy link
Author

@bjarthur I am also not sure why the axes got flipped?!

@montyvesselinov
Copy link
Author

@Mattriks maybe the small fonts used for the superscripts in the figure below create this crazy behavior. However, note here I create SVG file which I do not think uses Cairo.

@Mattriks
Copy link
Member

Mattriks commented Jul 5, 2022

The nbsp error in svg is different, and has been reported elsewhere (google it).

@montyvesselinov
Copy link
Author

montyvesselinov commented Jul 5, 2022

i am not worried about nbsp error @Mattriks . The problem is that figure is weird. Upside down. and crazy titles

@Mattriks
Copy link
Member

Mattriks commented Jul 5, 2022

Did you check if pinning Pango_jll to an earlier version fixes it? ]pin Pango_jll@1.42.4
Your Compose test above shows you have Pango_jll v1.50.3

@montyvesselinov
Copy link
Author

montyvesselinov commented Jul 5, 2022

@Mattriks Excellent suggestion! Both Pango_jll@1.42.4 and Pango_jll@1.47.0 work and the problem is fixed. I am fine to stick with an old version of Pango for the moment. However, it will be nice if this issue gets fixed soon or later. Thank you!

@nathanrboyer
Copy link

Pango_jll@1.47.0 did not work for me, but Pango_jll@1.42.4 did.

@montyvesselinov
Copy link
Author

I agree

I confirm with additional testing that Pango_jll@1.42.4 is needed. However, Pango_jll@1.47.0 and Pango_jll@1.50.0 fail!

]pin Pango_jll@1.42.4

@montyvesselinov
Copy link
Author

However, I hope the Gadfly/Compose gets fixed to work with the latest Pango_jll

@Mattriks
Copy link
Member

Mattriks commented Jul 7, 2022

But this issue doesn't seem to affect MacOS or Linux users, so not easy to fix.

@montyvesselinov
Copy link
Author

This continues to be an issue.

Now I tested it with the latest Julia v.1.10.

The only way to resolve the problem is to use Pango_jll@1.42.4

I am not sure why the support for Linux and Mac are only provided.

Many other users use Gadfly on Windows?!

Is there a way to resolve the problem?!

Please let me know. This has been outstanding for about 2 years now.

@montyvesselinov
Copy link
Author

I confirm that this is still an issue with the latest Pango_jll (Pango_jll v1.50.14+0)

@montyvesselinov
Copy link
Author

Gadfly.plot(x=1:5, y=1:5)

gives this:

image

and

Gadfly.plot(x=1:5000, y=1:5000)

produces this

image

@Mattriks
Copy link
Member

I wonder if the changes in Pango 1.51.x and 1.52.0 will fix things (https://github.com/GNOME/pango/blob/main/NEWS).

@montyvesselinov
Copy link
Author

I am also curious. It is just so painful at the moment to rely on old Pango versions.

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

No branches or pull requests

4 participants