[1]:
import numpy as np
import pandas as pd
from labcore.analysis.hv_pretty import setup_plotting, format_ax, add_legend, correctly_sized_figure, set_arial_font, save_plot_as_png

[2]:
df = pd.DataFrame({
    'x': np.linspace(0, 10, 100),
    'y': np.sin(np.linspace(0, 10, 100))
})

# Setup styling
setup_plotting()

# Create plot
plot = df.hvplot.line(x='x', y='y', label='sin(x)', line_width=2, color='crimson')

# Apply formatting
plot = format_ax(plot, title='Sine Wave', xlabel='X', ylabel='Y',
                 fontsize=32, title_fontsize=48, tick_fontsize=32)

# Add legend (if overlayed)
plot = add_legend(plot)

# Set size
plot = plot.opts(**correctly_sized_figure(2.75, 1.5))

# Set font
plot = plot.opts(hooks=[set_arial_font])

plot

[2]:
[3]:
save_plot_as_png(
    plot=plot,
    filename="sine_wave.png",
    width_in=2.75,
    height_in=1.5,
    dpi=300
)
[9]:
# Create sample data
df = pd.DataFrame({
    'x': np.linspace(0, 10, 100),
    'y1': np.sin(np.linspace(0, 10, 100)),
    'y2': np.cos(np.linspace(0, 10, 100))
})

# Create two separate line plots with labels
line1 = df.hvplot.line(x='x', y='y1', label='Sine Wave')
line2 = df.hvplot.line(x='x', y='y2', label='Cosine Wave')

setup_plotting()

# Overlay both lines
overlay = line1 * line2

overlay = add_legend(overlay, location='top_left', show=True)
overlay.opts(**correctly_sized_figure(2.75, 1.5))
overlay.opts(hooks=[set_arial_font])
overlay = format_ax(overlay, title='Sine Wave', xlabel='X', ylabel='Y',
                 fontsize=18, title_fontsize=24, tick_fontsize=18)
overlay
[9]:
[30]:
save_plot_as_png(
    plot=overlay,
    filename="sincos_wave.png",
    width_in=2.75,
    height_in=1.5,
    dpi=300
)