Giter Club home page Giter Club logo

Comments (6)

dd0 avatar dd0 commented on September 20, 2024 1

I implemented this approach, but after testing I don't think it's a complete solution due to #4202: GR and PGFPlotsX draw gridlines on top of axis lines, and so if they overlap the axis line will be drawn with the blended colour.

For example, with Plots 1.40.4 and plot(sin.(0:0.1:2π), yticks=-1:0.5:1, yrange=(-1,1)) we have:

out-orig

After flattening colours, equivalent to gridalpha = 1, foreground_color_grid = RGBA{Float64}(0.9,0.9,0.9,1.0):

out

The x-axis is covered by a gridline and is now gray:

sample-orig sample

This means that we can't currently assume that the transparent gridline is always drawn on the backround and replace it with a grid/background colour blend. It seems to me that the cleanest solution would be to first fix #4202.

from plots.jl.

BeastyBlacksmith avatar BeastyBlacksmith commented on September 20, 2024

Sounds reasonable. Would you like to work on it?

from plots.jl.

dd0 avatar dd0 commented on September 20, 2024

I'd be interested in working on a patch to remove (default) use of transparency for gridlines. I suggest that we keep the current default values, but replace them when preprocessing arguments, flattening as in the example above:

  • Replace foreground_color_grid with a blend of the current foreground_color_grid and background_color, using gridalpha as the ratio.
  • Set gridalpha to 1.
  • Same for foreground_color_minor_grid and minorgridalpha.

This way, we avoid breaking existing scripts that set one of gridalpha or foreground_color_grid and use the default value for the other.

Flattening grid colours in this way should not change the resulting plot, except that (tiny) grid intersections will now have the same colour as gridlines instead of the slightly darker overlap.

Does this sound like a reasonable approach? Should the behaviour be user-configurable (e.g. via a flattengridalpha parameter defaulting to true)?

from plots.jl.

BeastyBlacksmith avatar BeastyBlacksmith commented on September 20, 2024

That sounds like a good plan if you want to have this in a 1.x release.

It would also be fine to just remove the use of transparency on the v2 branch if you can wait for the release.

In any case this does not need to be user configurable.

from plots.jl.

mgkuhn avatar mgkuhn commented on September 20, 2024

@dd0 That sounds like a good approach.

By the way: I used ColorBlendModes.jl because it had the required compositing formulae readily available. But since it is a quite comprehensive package, I'm not necessarily suggesting to add it as a dependency. The basic compositing formulae to flatten two RGBA values are described in Section 11.3 of the ISO 32000:2008 PDF specification, and originally come from Porter and Duff: Compositing Digital Images (SIGGRAPH '84).

from plots.jl.

mgkuhn avatar mgkuhn commented on September 20, 2024

We probably also should check the code for locations where color=RGBA(0,0,0,0) is (ab)used to just indicate that something shouldn't be drawn, as that could be another way for transparency to enter a PDF backend.

from plots.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.