英文:
Filtering data in 3d scatter plotly creates plot with different third color other than the two colors specified in color scale, in angular
问题
我有一个3D的Plotly散点图,数据有一个标志true或false,而Plotly为true给出特定的颜色,我将其映射为0,而为false给出另一种颜色,我将其映射为1。
这是显示未经筛选的数据的Plotly图:
点击顶部的"Normal"将筛选数据,只显示正常点,这些点是蓝色的,然而,在筛选后,这是我得到的颜色:
当筛选异常值时,情况也是一样的。
标记具有颜色标度和颜色,颜色是一个由零和一组成的数组,在筛选后的数据中,它要么是一,要么是零。
在这里:
我希望零映射到颜色#17ADE0,而一映射到#A42286,如颜色标度中定义的,我不明白为什么会出现第三种颜色。
我尝试添加color_discrete_map:"identity"但迄今为止没有成功。
英文:
I have a 3d scatter plotly, the data has a flag true or false and the plotly gives specific color for true which I map to 0 and another color to false which I map to 1
this is the plotly showing unfiltered data
clicking on Normal at the top will filter the data to have only the normal points displayed which is in blue color however upon filtering this is the color I end up with
the Same thing happens when filtering outlier
the marker having color scale and color, color is an array of zeros and ones,which in the case of filtered data it is either ones or zeros
here it is:
I want the zeroes to map to the color #17ADE0" and the ones to the #A42286 as defined in color scale, I don't understand why a third color appears
I tried adding the color_discrete_map: "identity" with no success so far
答案1
得分: 0
问题是您需要设置最小和最大值以确保颜色比例覆盖整个范围,由于您的数据是零和一,我们可以直接设置它:
cmin: 0
cmax: 1
所以应该如下:
marker: {
colorscale: [
[0, '#17ADE0'],
[1, '#A42286']
],
cmin: 0,
cmax: 1
}
如果数据不是零和一,我们可以使用Math.min()和Math.max()来动态设置它们,以确定最小和最大值。
英文:
The issue is you need to set the min and max values to ensure color scale covers full range and as your data js zeros and ones we can set it directly
cmin:0
cmax :1
So it should be as follows :
marker: {
colorscale: [
[0, '#17ADE0'],[1,'#A42286']],
cmin: 0,cmax: 1
} };
In case the data is not zeros and ones we can set it using dynamically using Math.min() and Math.max to determine the minimum and maximum values
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论