- I'm trying to create a GraphScene and plot a function between 0 and 1.
- I want labels at 0.1 and 0.3.
- I am attempting to achieve this by passing
"x_labeled_nums": np.array([0.1, 0.3, 1])
and then "x_axis": {"decimal_number_config": {"num_decimal_places": 2}}
in the CONFIG
but I am still getting integers displayed on the x-axis where I am attempting to get it to render floats 0.1 and 0.3
class PlotFloats(GraphScene):
CONFIG = {
"x_min": 0,
"x_max": 1,
"x_axis_label": "X",
"y_min": 0,
"y_max": 2,
"y_axis_label": "Y",
"x_axis": {
"decimal_number_config": {"num_decimal_places": 2}
},
"function_color": RED,
"x_labeled_nums": np.array([0.1, 0.3, 1]),
}
def construct(self):
self.setup_axes(animate=True)
func_graph = self.get_graph(self.func_to_graph, self.function_color)
self.play(ShowCreation(func_graph))
def func_to_graph(self, x):
return max(0.05, min(1, (0.95 / 0.2) * (x - 0.1)))
Link to output