Shortcuts

24年高考新一卷第7题

../../_images/24%E5%B9%B4%E9%AB%98%E8%80%83%E6%96%B0%E4%B8%80%E5%8D%B7%E7%AC%AC7%E9%A2%98.svg
import math
import numpy as np

import alpsplot
from alpsplot.colormap import ting_color

x = np.arange(-2*math.pi, 2*math.pi, step=1e-2)
y1 = np.sin(x)
y2 = 2*np.sin(3*x-math.pi/6)

figure = alpsplot.Figure(figsize=(10, 5))
figure.ax.grid(axis='both', linewidth=1, alpha=0.5)
figure.ax.axhline(0, color='black', linewidth=1)
figure.ax.axvline(0, color='black', linewidth=1)

figure.set_title('24年高考新一卷第7题', font='Microsoft YaHei', size=25)
figure.set_axis_label(axis='x', text='x')
figure.set_axis_label(axis='y', text='y')
figure.set_axis_lim(
    'x',
    lim=[-2*math.pi, 2*math.pi],
    margin=0.3,
    piece=12,
    labels=[
        r'$-2\pi$', r'$-\frac{5}{3}\pi$', r'-$\frac{4}{3}\pi$',
        r'$-\pi$', r'$-\frac{2}{3}\pi$', r'$-\frac{1}{3}\pi$',
        r'$0$',
        r'$\frac{1}{3}\pi$', r'$\frac{2}{3}\pi$', r'$\pi$',
        r'$\frac{4}{3}\pi$', r'$\frac{5}{3}\pi$', r'$2\pi$',
    ],
)
figure.set_axis_lim('y', lim=[-2, 2], margin=(0.1, 0.75), piece=4)
figure.lineplot(x, y1, label=r'$\sin(x)$', color=ting_color['red'])
figure.lineplot(
    x, y2, label=r'$2\sin(3x-\frac{\pi}{6})$', color=ting_color['blue'])
figure.set_legend(ncols=2, loc='upper center')
figure.save(ext='.svg')

Docs

Access comprehensive developer documentation for AlpsPlot

View Docs