custom colorgradient heatmap in Julia - julia

I am currently using the Plots package and have it along with the PyPlot packages installed. With the code
using Plots
y = rand(10, 10)
pyplot()
plt = plot(y, st=:heatmap, clim=(0,1), color=:coolwarm, colorbar_title="y")
I am able to produce this
heat map
My question is how I can change the color gradient from its current setting (coolwarm which corresponds with a transition from red to gray to blue) to a new setting which has a gradient from red to green to blue. Is there some way to create a custom colorgradient and use that as an argument where I have 'coolwarm' in my sample code?

Yes. First of all there are numerous color libraries in Plots. Try clibraries(), then e.g. cgradients(:colorbrewer) or showlibrary(colorbrewer). In addition, you can make your own gradient with e.g. cgrad([:red, :green, :blue]) and pass that as the color argument.

Related

Define custom color_palette in Julia Plots package

I am currently using Plots package in Julia with pyplot as the backend. I can choose color_palette and make plots by
pyplot(color_palette=:delta)
Plots.plot(x, y)
What is the syntax to define and use a custom color palette according to, for example, Okade and Ito below, for color-blind-friendliness? Thanks!
Just pass a Vector of RGB - see the docs here https://docs.juliaplots.org/latest/colors/#Misc-1 But that particular palette is actually built into Plots - so you can get it by specifying theme(:wong2) before plotting, it will change the palette and color gradient for the duration of the session.

R Plotly set default color palette

In R, how do I set the default color palette for all plotly plots?
I know in plot_ly() you can set colors=palette, but that works only for scatter plots and not for line plots. For line plots you have to set the colors for each trace individually.
Apparently in the current plotly-version (4.8.0) this feature exists. You can set a color palette by using the colors-argument inside the plot_ly()-wrapper. However this only works if you use the color-argument in each add_trace.
my_palette=c('#0099FF','#00FF99') # create my palette
plot_ly(colors=my_palette) %>% ## set the palette
add_trace(x=1:4,y=rbinom(4,10,0.4),type='scatter',mode='lines',hoverinfo='skip',color=as.factor('my first trace')) %>%
add_trace(x=1:4,y=rbinom(4,10,0.5),type='scatter',mode='lines',hoverinfo='skip',color=as.factor('the second'))
Since the color-functionality is fairly new in plotly I am optimistic that this functionality will continue to exist in future package versions (>4.8.0.).
I only found your question over my own question and it turns out that both our problems have a similar solution

Color of errorbars with plots.jl

I'm using the package Plots with the pyplot backend.
By default, errorbars are black. How can I change their color? I want to set it to the same color as the line itself (which should be the default behaviour imho).
using Plots
plot(1:3,1:3,yerr=0.1) # produces a blue line with black errorbars
markerstrokecolor/mscsets the color. Normally you'd put points on the plot as well, rather than just the line with error bars, the default is thus to have the stroke around each point in the same color as the error bar. If you feel that another default is better you'd be welcome to open an issue on Plots.

ploting Gamma(Z) with maple

How do one plot the absolute value of the $|\Gamma(z)|$ with Maple?
As in the WIKI figure:
http://de.wikipedia.org/wiki/Gammafunktion#mediaviewer/File:Gamma_abs_3D.png
plot3d(
abs(GAMMA(x+I*y)), x= -4.6..5.1, y= -5.1..5.1,
view= [DEFAULT$2, 0..6],
labels= [Re(z), Im(z), ``], title = abs(GAMMA(z))
);
The command plots:-complexplot3d is intended as a convenient way of obtaining such plots (using z instead of the plot3d command with x+I*y, and putting in the labels automatically).
P := plots:-complexplot3d( abs(GAMMA(z)), z=-4-4*I..4+4*I,
view=[-4..4,-4..4,0..6], orientation=[-120,75] ):
For some reason, the surface stored in structure P gets some blue color that overrides the shading scheme.
P;
If we remove that COLOR substructure then the underlying shading scheme (which we could change in the original call, using the shading option) is revealed.
subsindets(P,specfunc(anything,COLOR),u->NULL);
I will submit a bug report about that heavy-handed blue coloring.

Plot different colours - Scilab

Is it possible to have different colours in my plot in Scilab? I use the mtlb_hold to hold the graph and it works fine, but my problem is that then I have the same colours in my graph. In Matlab with the hold command, I have different colours. Is it possible to have different colours in Scilab too?
Thank you in advance.
Just found it. In the plot function, for example plot(), you can pass a second argument which specifies the color that will be used. For example, you can use use b for blue color, g for green, r for red and call plot() like this: plot(z,"r").
The SciLab documentation provides examples for using colors:
https://help.scilab.org/doc/5.3.3/en_US/color.html
The plot2d()-function e.g. accepts an attribute style, where you can even specify a color for each function with its full name:
plot2d(x,[sin(x),cos(x)],style=[color("red"),color("green")]);

Resources