我不熟悉matplotlib。我正在尝试使用matplotlib创建二维网格。这是我第一次使用matplotlib处理任何不重要的事情。在
我决定将任务分成三个部分:
创建网格表(如下所示),为相应的列上色,并正确标记轴。这是我最需要帮助的一个。我最初的想法是在字典列表(或列表列表)中保存表的数据;数据结构可以保存一些关于哪些列被着色的元数据,然后我可以简单地根据这些数据创建matplot图-但是我还没有真正使用matplotlib进行任何绘图,可以在开始时提供一些帮助。
用坐标(行、列)在网格单元中绘制符号(例如“X”)
将表格另存为图片(这个很简单,我可以自己做)
下面是我希望使用matplotlib创建的网格表的图片:
我将非常感谢任何帮助我开始。在
PS:图像渲染得不是很好。表格中的水平线都是相同的粗细(即粗细),因此网格表格的视觉效果应该看起来像Excel工作表。在
[[编辑/更新]]
我想澄清一下,我要创造的是一种“象棋般”的棋盘。我已经成功地修改了Ricardo在他的答案中发布的代码片段,以尽可能接近(用我有限的matplotlib技能!)尽我所能把它放到游戏板上。然而,有几件事“缺失”:
x轴列标签是字符串,而不是数字,它们是字符串标签,例如AB1、AB2、AB3等。此外,这些标签是中点(即它们居中,或位于x轴刻度之间-而不是刻度本身)
我需要为给定的y轴值在特定的列中写入符号,例如,我可能想在列'AB2'中y轴值-1565.5处写入文本'foo'。
一旦我有了这个,我确信我将能够一起破解一些东西,从而得到我正在尝试编写的游戏——尤其是,因为我刚刚为Python开发人员购买了一个Matplotlib的副本。在
嗯。。。我想您可以通过要求matplotlib显示网格,并将条形图(用于给列着色)与散点图或直接文本绘制相结合来实现这一点
编辑:这可能有助于你开始。不过,还需要对蜱虫做些研究。在
相关问题 更多 >
编程相关推荐