我正在编写一个kivy应用程序,并且在更改x轴标签的值时遇到问题。我正在使用MeshLinePlot,我相信它应该接受x_axis和x_label作为列表。我已经包含了kivy.garden.graph基本的sin曲线代码。如果有人可以告诉我如何将x轴值更改为“ A”,“ B”,“ C”,“ D”。非常感谢。
from kivy.app import App
from kivy.garden.graph import Graph, MeshLinePlot
from kivy.uix.boxlayout import BoxLayout
from math import sin
class Grapher(BoxLayout):
def __init__(self, **kwargs):
super(Grapher, self).__init__(**kwargs)
self.size_hint=(1, 1)
self.orientation = 'vertical'
self.add_widget(self.graf())
def graf(self):
graph = Graph(xlabel='X', ylabel='Y', x_ticks_minor=5,
x_ticks_major=25, y_ticks_major=1,
y_grid_label=True, x_grid_label=True, padding=5,
x_grid=True, y_grid=True, xmin=-0, xmax=100, ymin=-1, ymax=1)
plot = MeshLinePlot(color=[1, 0, 0, 1])
plot.points = [(x, sin(x / 10.)) for x in range(0, 101)]
graph.add_plot(plot)
return graph
class myGraphApp(App):
def build(self):
return Grapher()
if __name__ == "__main__":
myGraphApp().run()