I am trying to set 0 values on my c3.js graph to white instead of the default grey value.
I am using
colors: d3.interpolateHslLong(d3.hsl(250, 1, 0.5), d3.hsl(0, 1, 0.5)) currently.
Does anyone know how to define the 0 value color? It seems no matter what I set the min and max values to, 0 remains grey.
Any help much appreciated.
White has 'lightness' equal to 1 (or 100%)
So, the first value will need have: d3.hsl(250, 1, 1), eg
d3.interpolateHslLong(d3.hsl(250, 1, 1), d3.hsl(0, 1, 0.5))
The hue and saturation (the first two values in the HSL constructor) can be anything, but they will affect the colour gradient to the second colour.
Related
Below COLOR/INDEX are information that I want to use for heatmap color palette
COLOR= ['#36abdf','#84d9a3','#f4d646','#e86000','#ff0000','#671b1b']
INDEX= [0, 0.001, 10, 25, 50, 75, 1]
I'm trying to make some HEATMAP which havs continuous (Gradient) color value.
My original Intension was that
Set Blue color ('#36abdf') for only '0' vlaue,
If value is bigger than 0, must start with green color('#84d9a3') and be gradually changed within color set for bigger value.
I found some code that can make LinearColormap through branca.colormap
cmap = b_cm.LinearColormap(colors=['#36abdf','#84d9a3','#f4d646','#e86000','#ff0000','#671b1b'], index=[0,0.001,25,50,75,90],vmin=0,vmax=100)
but it seems that I cannot use LinearColormap for color palette in seaborn/matplotlib heatmap
please let me introduce code that make color palette that I want.
I will be so appreciate if you let me know.
thx!!
def conv2d(x, W):
return tf.nn.conv2d(x, W, strides=[1, 1, 1, 1],
padding='SAME')
Can someone please kindly help me to understand, what is the functionality of strides in this place?. If possible, please explain each argument
The meaning of stride is how you jump forward in a dimension, your dimension are [batch, height, width, color].
If you set strides=[1, 1, 1, 1], the filter window will move 1 batch, 1 height pixel, 1 width pixel and 1 color pixel
If you set strides=[1, 2, 2, 1], the filter window will move 1 batch, 2 height pixel, 2 width pixel and 1 color pixel (Imagine that you have an image and a window, after processing, you move the window 2 pixel to the left and 2 pixel down)
The effect will result in the output with smaller size output (~1/2 height and 1/2 width)
The padding='SAME' will pad the border of image with zeros so that you can do convolution on the top-left pixel.
Other argument explain can be found here.
I have a mesh, with gradient color using this type of code :
It's nice and beautiful, but I want to reduce the precision of the gradient and make it less smooth.
Here's an exemple
I've got data on a JSON, wich gave me coordinate for vertices 0, 2, 4 and 6. I calculate the other one after that. I've got a value on vertice 0, 2, 4 and 6, which I use to get the color value of that point, in HSL (like 0 is 0 in HSL and 1 is 240 in HSL)
With than given value, 1, 3, 5 and 7 have a color value depending of the vertice on the same line, and 8 got value from a pondered calculus.
If 0, 6 have a value of 0.5(green), and 2, 4 have a value of 1(red), then 7 is green, 3 is red, and 1, 8, 5 have a value of 0.75 (yellow).
With my material and colorVertex, the pixels between those point are calculated and can take a infity of value between 1 and 0.5.
Now, I want to now if it's possible to limit this infinity of values to fixed one, so it will look like that
I can't subdivise my mesh because the final one is really big and can't spend much more on calculus time. Is there a way to change the interpolation used by three.js so the pixel between my vertices have the colormap/color range that I want?
Thanks in advance
I'm trying to blend two circles, one black and the other white. The parts where they intersect must be in grey.
I tried to use blend functions but I don't get the expected results.
The objective is to mix ONLY this two elements, other elements (like the background) can't mix there, and I don't know how to do this maintaining the 100% of the alpha channel.
This is my current render code, circle1 and circle2 are TextureRegion.
public void draw(Batch batch, float parentAlpha) {
super.draw(batch, parentAlpha);
batch.enableBlending();
batch.setBlendFunction(GL20.GL_ONE, GL20.GL_ONE);
batch.draw(circle1, c1.getX(), getY(), getWidth(), getHeight());
batch.draw(circle2, c2.getX(), getY(), getWidth(), getHeight());
}
This is an example of the color mix.
EDIT: Problem solved.
I did a test using Spritebatch, I drew a third circle with reduced opacity, this is the code used to test and the result:
Gdx.gl20.glEnable(GL20.GL_BLEND);
Gdx.gl20.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
shapeRenderer.setProjectionMatrix(camera.combined);
shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
shapeRenderer.setColor(1, 1, 1, 1f);
shapeRenderer.circle(15, 5, 5);
shapeRenderer.setColor(0, 0, 0, 1f);
shapeRenderer.circle(19, 5,5);
shapeRenderer.setColor(1, 1, 1, 0.5f);
shapeRenderer.circle(15, 5, 5);
shapeRenderer.end();
Gdx.gl20.glDisable(GL20.GL_BLEND);
I've never used libGDX so I'm not sure how the specific implementation goes, but I'll give you the general outline of what you're trying to achieve.
The most basic blending you can achieve is a linear blend between two colors with a single parameter t. Consider this example - let's say each color is represented by a single channel value for simplicity - black is 0.0 and white is 1.0. What you want to achieve is the mid range gray that is 0.5, to do this you would blend by scaling each channel appropriately ( black * 0.5 + white * 0.5 = 0.0 * 0.5 + 1.0 * 0.5 = 0.5)
A more sophisticated way of blending colors is by using the source alpha channel to govern the blend weight, so say you have a color black and a color white with 0.4 alpha, or opacity. You would blend using the following method black * 0.6 + white * 0.4 (your alpha sums up to 1.0), which would give you 0.4 a slightly "darker" than mid range gray.
To tie this back to your question, you specify the blend method as ONE, ONE, i.e, you're doing black * 1 + white * 1 which should result in 1 (all white).
Looking over the docs for libGDX, you have either the GL_ONE_MINUS_CONSTANT_ALPHA option for constant weight blend, or if you want to do "alpha blending" you could go for GL_ALPHA, GL_ONE_MINUS_SRC_ALPHA.
Hope this helps and clears up blending a bit :)
If I have matrix/data with line intensity values:
e.g.
0, 1, 2, 3, 4, 5, ..... M (where intensity value is gradually changing)
or
any random order of values
So if I use the first intensity set of data, (0, 1, 2, 3, 4, 5, ..... M), my line color should be gradually turning black to white. If I remember correctly, 0 is used to represent black and 255 is used to represent white? I would like to use a data of intensity values to draw 3D line with changing color/intensity.
How can I draw a 3D line with changing intensity/grayscale? I would appreciate any advice or recommendation.
You can use the 3D colored line plot tool from the file exchange and change the colormap to whatever you need.