Plotly contour plot colour scale granularity not matching custom colorscale
I am trying to create a contour plot with colours from black at a value of -1 to light grey at 0 to red at a value of 1.
I created a custom colorscale that looks like this, where I specified colours for each increment of 0.1 (20 increments from -1 to 1)
[ # Black -> Light grey
[0, 'rgb(0, 0, 0)'],[0.05, 'rgb(0, 0, 0)'],
[0.05, 'rgb(20, 20, 20)'],[0.1, 'rgb(20, 20, 20)'],
[0.1, 'rgb(40, 40, 40)'],[0.15, 'rgb(40, 40, 40)'],
[0.15, 'rgb(60, 60, 60)'],[0.2, 'rgb(60, 60, 60)'],
...
[0.4, 'rgb(160, 160, 160)'],[0.45, 'rgb(160, 160, 160)'],
[0.45, 'rgb(180, 180, 180)'],[0.5, 'rgb(180, 180, 180)'],
# Ligt Grey -> Red
[0.5, 'rgb(187, 162, 162)'],[0.55, 'rgb(187, 162, 162)'],
[0.55, 'rgb(194, 144, 144)'],[0.6, 'rgb(194, 144, 144)'],
[0.6, 'rgb(201, 126, 126)'],[0.65, 'rgb(201, 126, 126)'],
...
[0.9, 'rgb(243, 18, 18)'],[0.95, 'rgb(243, 18, 18)'],
[0.95, 'rgb(255, 0, 0)'],[1, 'rgb(255, 0, 0)']]
However, when I output the plot, my colorscale has increments of 0.2 and so it seems that not all of the colours I specified are shown.
Here is what I get
This is part of the code to display plot, I am not sure what would be needed to have more information.
data = [go.Contour(z=df.values.tolist(),x=list(df.columns),y=list(df.index),colorscale = colScale,zmin=-1,zmax=1)]
fig = go.Figure(data=data,layout=layout)
py.iplot(fig,contours= contour,filename='contPlot'+column)
I am looking for a way to have more colors displayed. Is there a way to display how many "splits" you want in the colour scale where it will interpolate between colours that have been specified ?
Thanks
python plotly
add a comment |
I am trying to create a contour plot with colours from black at a value of -1 to light grey at 0 to red at a value of 1.
I created a custom colorscale that looks like this, where I specified colours for each increment of 0.1 (20 increments from -1 to 1)
[ # Black -> Light grey
[0, 'rgb(0, 0, 0)'],[0.05, 'rgb(0, 0, 0)'],
[0.05, 'rgb(20, 20, 20)'],[0.1, 'rgb(20, 20, 20)'],
[0.1, 'rgb(40, 40, 40)'],[0.15, 'rgb(40, 40, 40)'],
[0.15, 'rgb(60, 60, 60)'],[0.2, 'rgb(60, 60, 60)'],
...
[0.4, 'rgb(160, 160, 160)'],[0.45, 'rgb(160, 160, 160)'],
[0.45, 'rgb(180, 180, 180)'],[0.5, 'rgb(180, 180, 180)'],
# Ligt Grey -> Red
[0.5, 'rgb(187, 162, 162)'],[0.55, 'rgb(187, 162, 162)'],
[0.55, 'rgb(194, 144, 144)'],[0.6, 'rgb(194, 144, 144)'],
[0.6, 'rgb(201, 126, 126)'],[0.65, 'rgb(201, 126, 126)'],
...
[0.9, 'rgb(243, 18, 18)'],[0.95, 'rgb(243, 18, 18)'],
[0.95, 'rgb(255, 0, 0)'],[1, 'rgb(255, 0, 0)']]
However, when I output the plot, my colorscale has increments of 0.2 and so it seems that not all of the colours I specified are shown.
Here is what I get
This is part of the code to display plot, I am not sure what would be needed to have more information.
data = [go.Contour(z=df.values.tolist(),x=list(df.columns),y=list(df.index),colorscale = colScale,zmin=-1,zmax=1)]
fig = go.Figure(data=data,layout=layout)
py.iplot(fig,contours= contour,filename='contPlot'+column)
I am looking for a way to have more colors displayed. Is there a way to display how many "splits" you want in the colour scale where it will interpolate between colours that have been specified ?
Thanks
python plotly
add a comment |
I am trying to create a contour plot with colours from black at a value of -1 to light grey at 0 to red at a value of 1.
I created a custom colorscale that looks like this, where I specified colours for each increment of 0.1 (20 increments from -1 to 1)
[ # Black -> Light grey
[0, 'rgb(0, 0, 0)'],[0.05, 'rgb(0, 0, 0)'],
[0.05, 'rgb(20, 20, 20)'],[0.1, 'rgb(20, 20, 20)'],
[0.1, 'rgb(40, 40, 40)'],[0.15, 'rgb(40, 40, 40)'],
[0.15, 'rgb(60, 60, 60)'],[0.2, 'rgb(60, 60, 60)'],
...
[0.4, 'rgb(160, 160, 160)'],[0.45, 'rgb(160, 160, 160)'],
[0.45, 'rgb(180, 180, 180)'],[0.5, 'rgb(180, 180, 180)'],
# Ligt Grey -> Red
[0.5, 'rgb(187, 162, 162)'],[0.55, 'rgb(187, 162, 162)'],
[0.55, 'rgb(194, 144, 144)'],[0.6, 'rgb(194, 144, 144)'],
[0.6, 'rgb(201, 126, 126)'],[0.65, 'rgb(201, 126, 126)'],
...
[0.9, 'rgb(243, 18, 18)'],[0.95, 'rgb(243, 18, 18)'],
[0.95, 'rgb(255, 0, 0)'],[1, 'rgb(255, 0, 0)']]
However, when I output the plot, my colorscale has increments of 0.2 and so it seems that not all of the colours I specified are shown.
Here is what I get
This is part of the code to display plot, I am not sure what would be needed to have more information.
data = [go.Contour(z=df.values.tolist(),x=list(df.columns),y=list(df.index),colorscale = colScale,zmin=-1,zmax=1)]
fig = go.Figure(data=data,layout=layout)
py.iplot(fig,contours= contour,filename='contPlot'+column)
I am looking for a way to have more colors displayed. Is there a way to display how many "splits" you want in the colour scale where it will interpolate between colours that have been specified ?
Thanks
python plotly
I am trying to create a contour plot with colours from black at a value of -1 to light grey at 0 to red at a value of 1.
I created a custom colorscale that looks like this, where I specified colours for each increment of 0.1 (20 increments from -1 to 1)
[ # Black -> Light grey
[0, 'rgb(0, 0, 0)'],[0.05, 'rgb(0, 0, 0)'],
[0.05, 'rgb(20, 20, 20)'],[0.1, 'rgb(20, 20, 20)'],
[0.1, 'rgb(40, 40, 40)'],[0.15, 'rgb(40, 40, 40)'],
[0.15, 'rgb(60, 60, 60)'],[0.2, 'rgb(60, 60, 60)'],
...
[0.4, 'rgb(160, 160, 160)'],[0.45, 'rgb(160, 160, 160)'],
[0.45, 'rgb(180, 180, 180)'],[0.5, 'rgb(180, 180, 180)'],
# Ligt Grey -> Red
[0.5, 'rgb(187, 162, 162)'],[0.55, 'rgb(187, 162, 162)'],
[0.55, 'rgb(194, 144, 144)'],[0.6, 'rgb(194, 144, 144)'],
[0.6, 'rgb(201, 126, 126)'],[0.65, 'rgb(201, 126, 126)'],
...
[0.9, 'rgb(243, 18, 18)'],[0.95, 'rgb(243, 18, 18)'],
[0.95, 'rgb(255, 0, 0)'],[1, 'rgb(255, 0, 0)']]
However, when I output the plot, my colorscale has increments of 0.2 and so it seems that not all of the colours I specified are shown.
Here is what I get
This is part of the code to display plot, I am not sure what would be needed to have more information.
data = [go.Contour(z=df.values.tolist(),x=list(df.columns),y=list(df.index),colorscale = colScale,zmin=-1,zmax=1)]
fig = go.Figure(data=data,layout=layout)
py.iplot(fig,contours= contour,filename='contPlot'+column)
I am looking for a way to have more colors displayed. Is there a way to display how many "splits" you want in the colour scale where it will interpolate between colours that have been specified ?
Thanks
python plotly
python plotly
asked Nov 20 '18 at 17:07
VincFortVincFort
357113
357113
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
Those are parameters related to the contours attribute:
go.Contour(
z=df.values.tolist(),
x=list(df.columns),
y=list(df.index),
colorscale=colScale,
contours=dict(
size=0.1,
start=-1,
end=1
)
)
also you don't need to graduate the color scale yourself, you should only use the base colors:
[
[0, 'rgb(0, 0, 0)'],[0.5, 'rgb(187, 162, 162)'],
[0.5, 'rgb(187, 162, 162)'],[1, 'rgb(255, 0, 0)']
]
Thanks for the second part of your answer, it helped me get better colourscale, however, the size part does not work and does not change the splits in the colourscale. Any idea why this is ?
– VincFort
Nov 21 '18 at 17:23
Yes, sorry, I forgot to swap thezmin
andzmax
forstart
andend
incontours
. I edited the answer, now it should work.
– vlizana
Nov 21 '18 at 19:59
add a comment |
I finally used ncontours to change the number of colour in the colour scale.
data = go.Contour(
z=df.values.tolist(),
x=list(df.columns),
y=list(df.index),
colorscale = colScale,
zmin=-1,
zmax=1,
ncontours=25)
1
Be careful withncontours
, from the docs: "Sets the maximum number of contour levels. The actual number of contours will be chosen automatically to be less than or equal to the value ofncontours
." meaning if you don't have enough data that number could be smaller.
– vlizana
Nov 21 '18 at 21:46
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53398042%2fplotly-contour-plot-colour-scale-granularity-not-matching-custom-colorscale%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Those are parameters related to the contours attribute:
go.Contour(
z=df.values.tolist(),
x=list(df.columns),
y=list(df.index),
colorscale=colScale,
contours=dict(
size=0.1,
start=-1,
end=1
)
)
also you don't need to graduate the color scale yourself, you should only use the base colors:
[
[0, 'rgb(0, 0, 0)'],[0.5, 'rgb(187, 162, 162)'],
[0.5, 'rgb(187, 162, 162)'],[1, 'rgb(255, 0, 0)']
]
Thanks for the second part of your answer, it helped me get better colourscale, however, the size part does not work and does not change the splits in the colourscale. Any idea why this is ?
– VincFort
Nov 21 '18 at 17:23
Yes, sorry, I forgot to swap thezmin
andzmax
forstart
andend
incontours
. I edited the answer, now it should work.
– vlizana
Nov 21 '18 at 19:59
add a comment |
Those are parameters related to the contours attribute:
go.Contour(
z=df.values.tolist(),
x=list(df.columns),
y=list(df.index),
colorscale=colScale,
contours=dict(
size=0.1,
start=-1,
end=1
)
)
also you don't need to graduate the color scale yourself, you should only use the base colors:
[
[0, 'rgb(0, 0, 0)'],[0.5, 'rgb(187, 162, 162)'],
[0.5, 'rgb(187, 162, 162)'],[1, 'rgb(255, 0, 0)']
]
Thanks for the second part of your answer, it helped me get better colourscale, however, the size part does not work and does not change the splits in the colourscale. Any idea why this is ?
– VincFort
Nov 21 '18 at 17:23
Yes, sorry, I forgot to swap thezmin
andzmax
forstart
andend
incontours
. I edited the answer, now it should work.
– vlizana
Nov 21 '18 at 19:59
add a comment |
Those are parameters related to the contours attribute:
go.Contour(
z=df.values.tolist(),
x=list(df.columns),
y=list(df.index),
colorscale=colScale,
contours=dict(
size=0.1,
start=-1,
end=1
)
)
also you don't need to graduate the color scale yourself, you should only use the base colors:
[
[0, 'rgb(0, 0, 0)'],[0.5, 'rgb(187, 162, 162)'],
[0.5, 'rgb(187, 162, 162)'],[1, 'rgb(255, 0, 0)']
]
Those are parameters related to the contours attribute:
go.Contour(
z=df.values.tolist(),
x=list(df.columns),
y=list(df.index),
colorscale=colScale,
contours=dict(
size=0.1,
start=-1,
end=1
)
)
also you don't need to graduate the color scale yourself, you should only use the base colors:
[
[0, 'rgb(0, 0, 0)'],[0.5, 'rgb(187, 162, 162)'],
[0.5, 'rgb(187, 162, 162)'],[1, 'rgb(255, 0, 0)']
]
edited Nov 21 '18 at 19:57
answered Nov 20 '18 at 23:33
vlizanavlizana
638215
638215
Thanks for the second part of your answer, it helped me get better colourscale, however, the size part does not work and does not change the splits in the colourscale. Any idea why this is ?
– VincFort
Nov 21 '18 at 17:23
Yes, sorry, I forgot to swap thezmin
andzmax
forstart
andend
incontours
. I edited the answer, now it should work.
– vlizana
Nov 21 '18 at 19:59
add a comment |
Thanks for the second part of your answer, it helped me get better colourscale, however, the size part does not work and does not change the splits in the colourscale. Any idea why this is ?
– VincFort
Nov 21 '18 at 17:23
Yes, sorry, I forgot to swap thezmin
andzmax
forstart
andend
incontours
. I edited the answer, now it should work.
– vlizana
Nov 21 '18 at 19:59
Thanks for the second part of your answer, it helped me get better colourscale, however, the size part does not work and does not change the splits in the colourscale. Any idea why this is ?
– VincFort
Nov 21 '18 at 17:23
Thanks for the second part of your answer, it helped me get better colourscale, however, the size part does not work and does not change the splits in the colourscale. Any idea why this is ?
– VincFort
Nov 21 '18 at 17:23
Yes, sorry, I forgot to swap the
zmin
and zmax
for start
and end
in contours
. I edited the answer, now it should work.– vlizana
Nov 21 '18 at 19:59
Yes, sorry, I forgot to swap the
zmin
and zmax
for start
and end
in contours
. I edited the answer, now it should work.– vlizana
Nov 21 '18 at 19:59
add a comment |
I finally used ncontours to change the number of colour in the colour scale.
data = go.Contour(
z=df.values.tolist(),
x=list(df.columns),
y=list(df.index),
colorscale = colScale,
zmin=-1,
zmax=1,
ncontours=25)
1
Be careful withncontours
, from the docs: "Sets the maximum number of contour levels. The actual number of contours will be chosen automatically to be less than or equal to the value ofncontours
." meaning if you don't have enough data that number could be smaller.
– vlizana
Nov 21 '18 at 21:46
add a comment |
I finally used ncontours to change the number of colour in the colour scale.
data = go.Contour(
z=df.values.tolist(),
x=list(df.columns),
y=list(df.index),
colorscale = colScale,
zmin=-1,
zmax=1,
ncontours=25)
1
Be careful withncontours
, from the docs: "Sets the maximum number of contour levels. The actual number of contours will be chosen automatically to be less than or equal to the value ofncontours
." meaning if you don't have enough data that number could be smaller.
– vlizana
Nov 21 '18 at 21:46
add a comment |
I finally used ncontours to change the number of colour in the colour scale.
data = go.Contour(
z=df.values.tolist(),
x=list(df.columns),
y=list(df.index),
colorscale = colScale,
zmin=-1,
zmax=1,
ncontours=25)
I finally used ncontours to change the number of colour in the colour scale.
data = go.Contour(
z=df.values.tolist(),
x=list(df.columns),
y=list(df.index),
colorscale = colScale,
zmin=-1,
zmax=1,
ncontours=25)
answered Nov 21 '18 at 17:29
VincFortVincFort
357113
357113
1
Be careful withncontours
, from the docs: "Sets the maximum number of contour levels. The actual number of contours will be chosen automatically to be less than or equal to the value ofncontours
." meaning if you don't have enough data that number could be smaller.
– vlizana
Nov 21 '18 at 21:46
add a comment |
1
Be careful withncontours
, from the docs: "Sets the maximum number of contour levels. The actual number of contours will be chosen automatically to be less than or equal to the value ofncontours
." meaning if you don't have enough data that number could be smaller.
– vlizana
Nov 21 '18 at 21:46
1
1
Be careful with
ncontours
, from the docs: "Sets the maximum number of contour levels. The actual number of contours will be chosen automatically to be less than or equal to the value of ncontours
." meaning if you don't have enough data that number could be smaller.– vlizana
Nov 21 '18 at 21:46
Be careful with
ncontours
, from the docs: "Sets the maximum number of contour levels. The actual number of contours will be chosen automatically to be less than or equal to the value of ncontours
." meaning if you don't have enough data that number could be smaller.– vlizana
Nov 21 '18 at 21:46
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53398042%2fplotly-contour-plot-colour-scale-granularity-not-matching-custom-colorscale%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown