Giter Club home page Giter Club logo

Comments (11)

wcharczuk avatar wcharczuk commented on August 16, 2024 2

seems awesome! two things come to mind with this, one enabling a function to be the provider of the color based on the (x,y) values, the second to bundle some prebuilt color map presets, i'll take a crack at both this weekend

from go-chart.

wcharczuk avatar wcharczuk commented on August 16, 2024

took a stab at this; see _examples/scatter/main.go for usage

from go-chart.

drgrib avatar drgrib commented on August 16, 2024

@wcharczuk Thanks for taking such quick action on it. I think we are getting somewhere here. The issues I see so far

  1. I'm not sure if the color spectrum in viridis.go is the right map for the official viridis. It seems to be a combination of magma / inferno and viridis. Specifically, because I don't think the pink/purple it has for the large dots in _examples/scatter/output.png occurs in viridis.
  2. I want to be able to color based only on my Z value, rather than having it tied to the radius of the dot. Is that possible with your new implementation? Maybe by providing a Z lookup closure that takes x and y as arguments then calling chart.Viridis with new values? Another option is adding a ZValues field to chart.Chart.

Thanks!

from go-chart.

drgrib avatar drgrib commented on August 16, 2024

@wcharczuk To clarify my 2nd point: I would like for my DotColorProvider to somehow have first class access to a Z value function using x and y as parameters just like DotWidthProvider does without having to use the radius but also use chart.Viridis for color values. I actually think that may be possible with your current implementation but it may not be obvious to me since I am new to your project.

from go-chart.

wcharczuk avatar wcharczuk commented on August 16, 2024

@drgrib yep, to your second point they're independent of each other, you can set a static dot width and set the DotColorProvider to provide the colors, i'll tweak the example to show that.

the color map i added was lifted from a matlab implementation, highly likely there are errors in it, lemme take another pass at finding a more official list of colors

from go-chart.

wcharczuk avatar wcharczuk commented on August 16, 2024

also added the jet colormap as a function (vs. a lookup table like i did with viridis)

from go-chart.

drgrib avatar drgrib commented on August 16, 2024

@wcharczuk Oh no! Not jet! Viridis was created partly because jet led to so many misdiagnoses by doctors who used it. Seriously, I think it is best to let it die with old software and discontinue its use. Please listen to the brief statement from the matplotlib creator in my link. People may have seriously died from doctors using it.

And thanks for clarifying on my second point. I can help you with a pull request on viridis since I am familiar with it once you have implemented the modification to the example that will help me understand how to use DotColorProvider without modifying the radius. I have my own data set that will help me verify it quickly.

from go-chart.

wcharczuk avatar wcharczuk commented on August 16, 2024

so the code i use to generate the color based on (xrange, yrange, x, y) is in viridis.go, i dumped a 256 sample array from a post online, have been looking into how to do it programmatically (vs. with a prebuilt array of values). i put the jet map in there because there was a quick sample on how to generate the color based on a normalized [0.0,1.0) value.

if you look in the scatter example, i'm already using a dot width separate from the color, so you should be good to go there.

from go-chart.

drgrib avatar drgrib commented on August 16, 2024

@wcharczuk Okay. I will be modifying the code base today. Hopefully I'll be able to get you a pull request today or tomorrow.

from go-chart.

drgrib avatar drgrib commented on August 16, 2024

@wcharczuk One large change that I will be proposing is two different interfaces involved in this process. I want to change the signature of ColorProvider to match the signature you used for getJetColour in jet.go:

type ColorProvider func(v, vmin, vmax float64) drawing.Color

These will be the interfaces implemented by color maps like Viridis.

I want to then create a new interface called DotColorProvider to assign to the DotColorProvider attribute of the same name in Stlye:

type DotColorProvider func(xrange, yrange Range, x, y float64) drawing.Color

Then instances of DotColorProvider will call instances of ColorProvider. Without this change, the current implementations for color maps will be hard-coded. For Viridis, it is currently hard-coded to dot size. For Jet, it is currently hard-coded to y-position. Using these two new interfaces will free the colors up to be associated with whatever values we wish when assigning the Style.

from go-chart.

drgrib avatar drgrib commented on August 16, 2024

Implemented in #34

from go-chart.

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.