본문으로 건너뛰기
cccskills
무료GitHub에 공개

physics-visualization

Publication-quality physics plots — vector fields, streamlines, contour maps, 3D surfaces, phase space, spectrograms, and animations. Optimized for journal submission with LaTeX labels, proper colormaps, and multi-panel layouts.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

설치 방법 보기

포함된 파일(1)

  • SKILL.md7.7 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Physics Visualization

Overview

Generate publication-quality figures for physics: vector fields, streamlines, contour plots, 3D surfaces, phase diagrams, spectrograms, and animations. All plots use LaTeX rendering, proper colormaps, and journal-ready formatting.

When to Use

  • Any physics result that needs a figure
  • Vector fields (E&M, fluid flow, gravitational fields)
  • Contour/heatmap plots (potential fields, temperature distributions, wavefunctions)
  • Phase space plots (trajectories, Poincare sections)
  • 3D surface plots (energy landscapes, wavefunctions)
  • Animations (time-evolving systems)
  • Multi-panel comparison figures

Setup

import numpy as np
import matplotlib
matplotlib.use('Agg')  # non-interactive backend for scripts
import matplotlib.pyplot as plt
from matplotlib import cm
from mpl_toolkits.mplot3d import Axes3D

# Publication-quality defaults
plt.rcParams.update({
    'font.size': 12,
    'axes.labelsize': 14,
    'axes.titlesize': 15,
    'xtick.labelsize': 11,
    'ytick.labelsize': 11,
    'legend.fontsize': 11,
    'figure.dpi': 150,
    'savefig.dpi': 300,
    'savefig.bbox': 'tight',
    'axes.grid': True,
    'grid.alpha': 0.3,
    'lines.linewidth': 1.5,
})

# Enable LaTeX if available
try:
    plt.rcParams.update({
        'text.usetex': True,
        'font.family': 'serif',
    })
except:
    pass  # fallback to mathtext

Core Plot Types

1. Vector Field

def plot_vector_field(ax, X, Y, U, V, title='', normalize=True, cmap='viridis'):
    """Plot a 2D vector field with magnitude coloring."""
    magnitude = np.sqrt(U**2 + V**2)
    if normalize:
        U_n = U / (magnitude + 1e-10)
        V_n = V / (magnitude + 1e-10)
    else:
        U_n, V_n = U, V

    q = ax.quiver(X, Y, U_n, V_n, magnitude, cmap=cmap, alpha=0.8)
    plt.colorbar(q, ax=ax, label='|F|')
    ax.set_title(title)
    ax.set_aspect('equal')
    return q

# Example: Electric dipole field
x = np.linspace(-3, 3, 20)
y = np.linspace(-3, 3, 20)
X, Y = np.meshgrid(x, y)

# Dipole at (±0.5, 0)
def dipole_field(X, Y, d=0.5):
    r_plus = np.sqrt((X-d)**2 + Y**2)
    r_minus = np.sqrt((X+d)**2 + Y**2)
    Ex = (X-d)/r_plus**3 - (X+d)/r_minus**3
    Ey = Y/r_plus**3 - Y/r_minus**3
    return Ex, Ey

Ex, Ey = dipole_field(X, Y)
fig, ax = plt.subplots(figsize=(8, 8))
plot_vector_field(ax, X, Y, Ex, Ey, title='Electric Dipole Field')
ax.set_xlabel('x [m]')
ax.set_ylabel('y [m]')
plt.savefig('vector_field.png', dpi=150, bbox_inches='tight')

2. Streamlines

fig, ax = plt.subplots(figsize=(10, 8))
x_fine = np.linspace(-3, 3, 100)
y_fine = np.linspace(-3, 3, 100)
X_f, Y_f = np.meshgrid(x_fine, y_fine)
Ex_f, Ey_f = dipole_field(X_f, Y_f)
magnitude = np.sqrt(Ex_f**2 + Ey_f**2)

strm = ax.streamplot(X_f, Y_f, Ex_f, Ey_f, color=np.log10(magnitude+1e-3),
                      cmap='inferno', density=2, linewidth=1, arrowsize=1.5)
plt.colorbar(strm.lines, ax=ax, label=r'$\log_{10}|E|$')
ax.plot([-0.5, 0.5], [0, 0], 'ro', markersize=10, label='Charges')
ax.set_xlabel('x [m]')
ax.set_ylabel('y [m]')
ax.set_title('Electric Field Streamlines')
ax.legend()
plt.savefig('streamlines.png', dpi=150, bbox_inches='tight')

3. Contour / Heatmap

def plot_contour(ax, X, Y, Z, title='', levels=20, cmap='RdBu_r', symmetric=True):
    """Contour plot with optional symmetric colorbar (good for potentials)."""
    if symmetric:
        vmax = np.max(np.abs(Z))
        vmin = -vmax
    else:
        vmin, vmax = Z.min(), Z.max()

    cf = ax.contourf(X, Y, Z, levels=levels, cmap=cmap, vmin=vmin, vmax=vmax)
    cs = ax.contour(X, Y, Z, levels=levels, colors='k', linewidths=0.3, alpha=0.5)
    plt.colorbar(cf, ax=ax, label=title)
    ax.clabel(cs, inline=True, fontsize=8, fmt='%.1f')
    ax.set_aspect('equal')
    return cf

# Example: 2D wavefunction |ψ|²
r = np.linspace(-5, 5, 200)
X, Y = np.meshgrid(r, r)
R = np.sqrt(X**2 + Y**2)
# Hydrogen 2p orbital (simplified)
psi = R * np.exp(-R/2) * X / R  # p_x orbital
psi_sq = np.abs(psi)**2

fig, ax = plt.subplots(figsize=(8, 7))
plot_contour(ax, X, Y, psi_sq, title=r'$|\psi_{2p}|^2$', symmetric=False, cmap='hot')
ax.set_xlabel('x [a₀]')
ax.set_ylabel('y [a₀]')
ax.set_title(r'Hydrogen $2p_x$ Probability Density')
plt.savefig('wavefunction.png', dpi=150, bbox_inches='tight')

4. 3D Surface

fig = plt.figure(figsize=(10, 8))
ax = fig.add_subplot(111, projection='3d')

# Energy landscape
x = np.linspace(-2, 2, 100)
y = np.linspace(-2, 2, 100)
X, Y = np.meshgrid(x, y)
Z = (X**2 - 1)**2 + Y**2  # double-well potential

surf = ax.plot_surface(X, Y, Z, cmap='coolwarm', alpha=0.8,
                       linewidth=0, antialiased=True)
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_zlabel('V(x,y)')
ax.set_title('Double-Well Potential')
fig.colorbar(surf, ax=ax, shrink=0.6, label='V')
plt.savefig('surface_3d.png', dpi=150, bbox_inches='tight')

5. Animation

from matplotlib.animation import FuncAnimation, PillowWriter

def create_animation(update_func, n_frames, fig, interval=50, filename='animation.gif'):
    """Create and save an animation."""
    anim = FuncAnimation(fig, update_func, frames=n_frames, interval=interval, blit=True)
    writer = PillowWriter(fps=1000/interval)
    anim.save(filename, writer=writer)
    print(f"Animation saved: {filename}")
    return anim

# Example: wave propagation
fig, ax = plt.subplots(figsize=(10, 4))
x = np.linspace(0, 10, 500)
line, = ax.plot(x, np.sin(x), 'b-', linewidth=2)
ax.set_ylim(-1.5, 1.5)
ax.set_xlabel('x')
ax.set_ylabel('u(x,t)')
time_text = ax.text(0.02, 0.95, '', transform=ax.transAxes)

def update(frame):
    t = frame * 0.05
    y = np.sin(2*np.pi*(x - t)) * np.exp(-0.1*t)
    line.set_ydata(y)
    time_text.set_text(f't = {t:.2f}')
    return line, time_text

create_animation(update, 200, fig, interval=33, filename='wave.gif')

6. Multi-Panel Figure

def multi_panel(n_rows, n_cols, figsize=None, sharex=False, sharey=False):
    """Create a multi-panel figure with consistent styling."""
    if figsize is None:
        figsize = (5*n_cols, 4*n_rows)
    fig, axes = plt.subplots(n_rows, n_cols, figsize=figsize,
                              sharex=sharex, sharey=sharey)
    # Add panel labels (a), (b), (c), ...
    if n_rows * n_cols > 1:
        for i, ax in enumerate(np.atleast_1d(axes).flat):
            label = chr(ord('a') + i)
            ax.text(-0.12, 1.05, f'({label})', transform=ax.transAxes,
                    fontsize=14, fontweight='bold', va='top')
    return fig, axes

Colormap Guide

Data TypeRecommended ColormapWhy
Sequential (magnitude, density)viridis, plasma, infernoPerceptually uniform, colorblind-safe
Diverging (potential, temperature anomaly)RdBu_r, coolwarmSymmetric around zero
Cyclic (phase, angle)twilight, hsvWraps around
Binary (positive/negative)bwrClear sign distinction

Never use jet or rainbow — they are not perceptually uniform and mislead.

Save Format Guide

FormatWhen to Use
PNG (300 dpi)General use, presentations
PDFJournal submission, vector graphics
SVGWeb, editable vector
EPSLegacy journals requiring EPS

Always save both PNG and PDF:

plt.savefig('figure.png', dpi=300, bbox_inches='tight')
plt.savefig('figure.pdf', bbox_inches='tight')

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Simplest distributed training API. 4 lines to add distributed support to any PyTorch script. Unified API for DeepSpeed/FSDP/Megatron/DDP. Automatic device placement, mixed precision (FP16/BF16/FP8). Interactive config, single launch command. HuggingFace ecosystem standard.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

huang-sh/DeepScience42026년 7월 15일 업데이트

ADMET property prediction for drug candidates. Full pharmacokinetic panel (Caco-2, PPB, clearance, CYP), toxicity (hERG, AMES, DILI), drug-likeness (Lipinski, QED), using RDKit descriptors and TDC models.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

huang-sh/DeepScience42026년 7월 15일 업데이트

Interpretable ADMET analysis with mechanistic reasoning. Maps liabilities to structural causes and biological pathways. Based on CoTox (Park 2025) and DrugR (Liu 2026).

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

huang-sh/DeepScience42026년 7월 15일 업데이트

aeon

무료

This skill should be used for time series machine learning tasks including classification, regression, clustering, forecasting, anomaly detection, segmentation, and similarity search. Use when working with temporal data, sequential patterns, or time-indexed observations requiring specialized algorithms beyond standard ML approaches. Particularly suited for univariate and multivariate time series analysis with scikit-learn compatible APIs.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

huang-sh/DeepScience42026년 7월 15일 업데이트

arboreto

무료

Infer gene regulatory networks (GRNs) from gene expression data using scalable algorithms (GRNBoost2, GENIE3). Use when analyzing transcriptomics data (bulk RNA-seq, single-cell RNA-seq) to identify transcription factor-target gene relationships and regulatory interactions. Supports distributed computation for large-scale datasets.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

huang-sh/DeepScience42026년 7월 15일 업데이트

astropy

무료

Comprehensive Python library for astronomy and astrophysics. This skill should be used when working with astronomical data including celestial coordinates, physical units, FITS files, cosmological calculations, time systems, tables, world coordinate systems (WCS), and astronomical data analysis. Use when tasks involve coordinate transformations, unit conversions, FITS file manipulation, cosmological distance calculations, time scale conversions, or astronomical data processing.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

huang-sh/DeepScience42026년 7월 15일 업데이트

huang-sh의 스킬 모두 보기

이 스킬의 문제 신고