mirror of
https://github.com/3b1b/manim.git
synced 2025-08-05 16:49:03 +00:00
Change axis defaults
This commit is contained in:
parent
f31cf2e30f
commit
dbe33f9382
1 changed files with 17 additions and 33 deletions
|
@ -231,29 +231,10 @@ class IntroducePlot(Scene):
|
||||||
def get_axes(self, width=12, height=6):
|
def get_axes(self, width=12, height=6):
|
||||||
n_cases = len(CASE_DATA)
|
n_cases = len(CASE_DATA)
|
||||||
axes = Axes(
|
axes = Axes(
|
||||||
x_min=0,
|
x_range=(0, n_cases),
|
||||||
x_max=n_cases,
|
y_range=(0, 25000, 1000),
|
||||||
x_axis_config={
|
width=width,
|
||||||
"tick_frequency": 1,
|
height=height,
|
||||||
"include_tip": False,
|
|
||||||
},
|
|
||||||
y_min=0,
|
|
||||||
y_max=25000,
|
|
||||||
y_axis_config={
|
|
||||||
"unit_size": 1 / 2500,
|
|
||||||
"tick_frequency": 1000,
|
|
||||||
"include_tip": False,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
axes.x_axis.set_width(
|
|
||||||
width,
|
|
||||||
stretch=True,
|
|
||||||
about_point=axes.c2p(0, 0),
|
|
||||||
)
|
|
||||||
axes.y_axis.set_height(
|
|
||||||
height,
|
|
||||||
stretch=True,
|
|
||||||
about_point=axes.c2p(0, 0),
|
|
||||||
)
|
)
|
||||||
axes.center()
|
axes.center()
|
||||||
axes.to_edge(DOWN, buff=LARGE_BUFF)
|
axes.to_edge(DOWN, buff=LARGE_BUFF)
|
||||||
|
@ -289,18 +270,21 @@ class IntroducePlot(Scene):
|
||||||
axes.add(labels, extra_ticks)
|
axes.add(labels, extra_ticks)
|
||||||
|
|
||||||
# Adjust y ticks
|
# Adjust y ticks
|
||||||
axes.y_axis.tick_marks.stretch(0.5, 0)
|
axes.y_axis.ticks.stretch(0.5, 0)
|
||||||
axes.y_axis.tick_marks[0::5].stretch(2, 0)
|
axes.y_axis.ticks[0::5].stretch(2, 0)
|
||||||
|
|
||||||
# Add y_axis_labels
|
# Add y_axis_labels
|
||||||
def get_y_labels(axes, y_values):
|
def get_y_labels(axes, y_values):
|
||||||
labels = VGroup()
|
labels = VGroup()
|
||||||
for y in y_values:
|
for y in y_values:
|
||||||
label = TextMobject(f"{y}k")
|
try:
|
||||||
label.set_height(0.25)
|
label = TextMobject(f"{y}k")
|
||||||
tick = axes.y_axis.tick_marks[y]
|
label.set_height(0.25)
|
||||||
always(label.next_to, tick, LEFT, SMALL_BUFF)
|
tick = axes.y_axis.ticks[y]
|
||||||
labels.add(label)
|
always(label.next_to, tick, LEFT, SMALL_BUFF)
|
||||||
|
labels.add(label)
|
||||||
|
except IndexError:
|
||||||
|
pass
|
||||||
return labels
|
return labels
|
||||||
|
|
||||||
main_labels = get_y_labels(axes, range(5, 30, 5))
|
main_labels = get_y_labels(axes, range(5, 30, 5))
|
||||||
|
@ -311,7 +295,7 @@ class IntroducePlot(Scene):
|
||||||
tiny_labels = VGroup()
|
tiny_labels = VGroup()
|
||||||
tiny_ticks = VGroup()
|
tiny_ticks = VGroup()
|
||||||
for y in range(200, 1000, 200):
|
for y in range(200, 1000, 200):
|
||||||
tick = axes.y_axis.tick_marks[0].copy()
|
tick = axes.y_axis.ticks[0].copy()
|
||||||
point = axes.c2p(0, y)
|
point = axes.c2p(0, y)
|
||||||
tick.move_to(point)
|
tick.move_to(point)
|
||||||
label = Integer(y)
|
label = Integer(y)
|
||||||
|
@ -378,8 +362,8 @@ class Thumbnail(IntroducePlot):
|
||||||
# self.add(title)
|
# self.add(title)
|
||||||
# self.add(subtitle)
|
# self.add(subtitle)
|
||||||
|
|
||||||
title = TextMobject("How is ", "COVID-19\\\\", "currently growing?")
|
title = TextMobject("The early warning\\\\of ", "COVID-19\\\\")
|
||||||
title[1].set_color(RED)
|
title.set_color_by_tex("COVID", RED)
|
||||||
title.set_height(2.5)
|
title.set_height(2.5)
|
||||||
title.to_edge(UP, buff=LARGE_BUFF)
|
title.to_edge(UP, buff=LARGE_BUFF)
|
||||||
self.add(title)
|
self.add(title)
|
||||||
|
|
Loading…
Add table
Reference in a new issue