Comments (6)
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:
After flattening colours, equivalent to gridalpha = 1, foreground_color_grid = RGBA{Float64}(0.9,0.9,0.9,1.0)
:
The x-axis is covered by a gridline and is now gray:
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.
Sounds reasonable. Would you like to work on it?
from plots.jl.
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 currentforeground_color_grid
andbackground_color
, usinggridalpha
as the ratio. - Set
gridalpha
to 1. - Same for
foreground_color_minor_grid
andminorgridalpha
.
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.
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.
@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.
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)
- [BUG] Misleading behaviour when plotting complex numbers when real part may be 0 HOT 2
- [BUG] Heatmap colorbar ticks with many digits get clipped
- [BUG] Plot annotations in awkward location
- [BUG] Plotting images inserts unwanted padding
- [BUG] When using permute = (:x, :y) on a bar plot the bars are not automatically centered
- [BUG] Colorbar colors don't match actual colors in `contourf` plot
- [BUG] twinx() doesn't work nicely with framestyle and ticks
- [BUG] Dynamically assigning false for legendPosition property in plotly js is not working HOT 1
- [BUG] keyword `arrow` doesn't work for 3d plot
- [BUG] gksqt can't find version Qt_6.7 on Fedora 39
- [BUG][UnicodePlotsBackend] `showable` for `image/png` and `UnicodePlotsBackend` is unreliable
- [BUG] Specifying 'errorbar' with asymmetric error bar data with 'Unitful' values returns DimensionError
- [BUG]
- [BUG] grid checks sum to 1 but fails due to numerical approximation.
- [FR] Show legend by default only if labels have been set
- [FR] Sticks with arrow heads
- New colorscheme for Plots.jl 2.0 HOT 11
- [BUG] Plots fails to precompile on MacOS Apple Silicon with Julia 1.10.4 HOT 1
- [BUG] [GR] axis log scale does not work properly in surface() plots
- [FR] create syntax myplot!(p, args...; kwargs...) for user recipes HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from plots.jl.