Comments (11)
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.
took a stab at this; see _examples/scatter/main.go
for usage
from go-chart.
@wcharczuk Thanks for taking such quick action on it. I think we are getting somewhere here. The issues I see so far
- 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. - 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
andy
as arguments then callingchart.Viridis
with new values? Another option is adding aZValues
field tochart.Chart
.
Thanks!
from go-chart.
@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.
@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.
also added the jet colormap as a function (vs. a lookup table like i did with viridis)
from go-chart.
@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.
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.
@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.
@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.
Implemented in #34
from go-chart.
Related Issues (20)
- Syntax error in _examples directory
- Plot image with interactive interface
- Barchart XAxis Stroke inside bars
- help...... how to show each value for bar chart? HOT 2
- Pie does not return image with value 0 input
- Unable to generate graph
- It's possible to reduce number of labels on X Axis? HOT 3
- How to reorder bar charts? HOT 3
- How to draw lines on the top of bars?
- Single element donut charts renders as an empty canvas HOT 1
- How to show series name like this? HOT 1
- Double bar graphs HOT 1
- Negative and positive values in a barchart HOT 3
- Is it possible to create a new tag targeting the latest commit? HOT 1
- CVE-2022-41727 golang.org/x/image HOT 1
- customize the stacked_bar's heigth
- [QUESTION] - Possibility to render chart in xml to png
- Request: bottom legend
- Flat series can't be rendered (CPU spinning) HOT 4
- Horizontal Bar Chart
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 go-chart.