Python Pyx:color.gradient graph.style.rect
Python Pyx: color.gradient for graph.style.rect
我想用 python 中的 PyX
包制作密度图。
我用代码
from pyx import *
import numpy
import math
from pyx.graph import axis
g = graph.graphxy(height=8, width=8,
x=graph.axis.linear(min=0.0, max=2.0, title=r"$x-axis$"),
y=graph.axis.linear(min=0.0, max=2.0, title=r'$y-axis$'))
g.plot(graph.data.file("datatotest.dat", xmin=1, xmax=2, ymin=3, ymax=4, color=5, title=r"$bar$"),
[graph.style.rect(gradient=color.gradient.Gray)]
)
g.writePDFfile()
我使用数据
0 1 0 1 0.12
0 1 1 2 0.56
1 2 0 1 0.98
1 2 1 2 0.23
我得到了结果
我想要更多有趣的颜色。
但是使用color.gradient.Rainbow
给出了错误信息:
"colorspace string not available for hsb colors"
.
我在 color.gradient.Hue.
和使用 Reverse 时遇到类似的错误。
问题:这里除了灰色还有什么颜色渐变?
问题是由于右侧的渐变和此处使用位图进行优化以实现良好压缩。不幸的是,位图不适用于 HSB 颜色。现在,解决方案相当简单,因为彩虹(和其他渐变)也转换为不同的颜色 space。在您的情况下,您可以使用 color.rgbgradient.Rainbow 或 color.cmykgradient.Rainbow 等,具体取决于您希望在输出中使用哪种颜色 space。
我曾经做过类似的事情。我为数据与 seaborn.heatmap 的一些相关性创建了一个热图,你应该试试这个。
https://seaborn.pydata.org/generated/seaborn.heatmap.html
我想用 python 中的 PyX
包制作密度图。
我用代码
from pyx import *
import numpy
import math
from pyx.graph import axis
g = graph.graphxy(height=8, width=8,
x=graph.axis.linear(min=0.0, max=2.0, title=r"$x-axis$"),
y=graph.axis.linear(min=0.0, max=2.0, title=r'$y-axis$'))
g.plot(graph.data.file("datatotest.dat", xmin=1, xmax=2, ymin=3, ymax=4, color=5, title=r"$bar$"),
[graph.style.rect(gradient=color.gradient.Gray)]
)
g.writePDFfile()
我使用数据
0 1 0 1 0.12
0 1 1 2 0.56
1 2 0 1 0.98
1 2 1 2 0.23
我得到了结果
我想要更多有趣的颜色。
但是使用color.gradient.Rainbow
给出了错误信息:
"colorspace string not available for hsb colors"
.
我在 color.gradient.Hue.
和使用 Reverse 时遇到类似的错误。
问题:这里除了灰色还有什么颜色渐变?
问题是由于右侧的渐变和此处使用位图进行优化以实现良好压缩。不幸的是,位图不适用于 HSB 颜色。现在,解决方案相当简单,因为彩虹(和其他渐变)也转换为不同的颜色 space。在您的情况下,您可以使用 color.rgbgradient.Rainbow 或 color.cmykgradient.Rainbow 等,具体取决于您希望在输出中使用哪种颜色 space。
我曾经做过类似的事情。我为数据与 seaborn.heatmap 的一些相关性创建了一个热图,你应该试试这个。 https://seaborn.pydata.org/generated/seaborn.heatmap.html