Coder Social home page Coder Social logo

Problem with area colors about plotly.js HOT 5 CLOSED

plotly avatar plotly commented on May 6, 2024
Problem with area colors

from plotly.js.

Comments (5)

mdtusz avatar mdtusz commented on May 6, 2024 1

Yes, the default behaviour for 'tonexty' seems to be to fill to the x-axis for the first dataset (although I'm new so I could be mistaken!). It you would like that fill to be "empty", you can set fill: 'none', and only the curve will be drawn.

'tozeroy' will always fill between the curve and the x-axis. It becomes a challenge of presentation because the "bottom" dataset will become obscured if any "layers" on top have values greater (or less than, in the case of negative values). The reason for having the overlaid fills is so as to preserve visibility of all the data. If you would like to get rid of the overlaid colours, you can set fillcolor using a string containing a hex code, or a rgb/rgba string such as 'rgba(241,111,203,1)'. By setting a full opacity of 1 however, any dataset value less than a successive dataset value (at an equivalent x-value) will be hidden.

from plotly.js.

mdtusz avatar mdtusz commented on May 6, 2024

I believe that this is the expected behaviour - the data is plotted in order it is placed in the array, so in your first example, the dataset with larger y-values (Query 2) is plotted in blue, then the next dataset is plotted in orange, and the area is filled (to the next y). When using fill: 'tonexty' you can think of the filled areas between data sets as the area between two successive curves, so their order will determine the fill areas. In your second example, you will see where orange plot dips below the x axis, the fill colour is the combined blue/orange.

from plotly.js.

prog8 avatar prog8 commented on May 6, 2024

I think now I get it but why blue area on the first chart is touching Y=0, only because there is no "next Y"?

BTW It seems I should use tozeroy instead of tonexty?

from plotly.js.

prog8 avatar prog8 commented on May 6, 2024

I tried tozeroy as well and it doesn't work good - it looks quite bad. From what I understand tonexty should work fine but only when I manually sort data series that the one with higher values is added first. Unfortunately this is not always so obvious because values can be sometimes higher and sometimes lower.

from plotly.js.

alexcjohnson avatar alexcjohnson commented on May 6, 2024

@mdtusz spot on - 'tonexty' behaves identically to 'tozeroy' for the first trace. This is driven by the use case of filled area charts, where you always want to fill the first trace to zero and all the others to the adjacent trace - set set all the traces to the same fill mode 'tonexty' and this is what you get.

from plotly.js.

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.