"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.3class 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)))
I had the same issue as you and decided to look at the code behind manim to find why the number was rounding. It turns that you made a small error:
Replace "x_axis"
"x_axis": {
"decimal_number_config": {"num_decimal_places": 2}
},
With "x_axis_config"
"x_axis_config": {
"decimal_number_config": {"num_decimal_places": 2}
},
Because the x_axis_config has the decimal_number_config setting.