Menu

Statistical
Static
49 Python scripts generated for tuning curve this week

Tuning Curve

Chart overview

A tuning curve shows how a neuron's mean firing rate changes across systematically varied stimulus values, such as visual orientation or auditory frequency.

Key points

  • Neuroscientists fit these data with a von Mises or Gaussian function to extract preferred stimulus, tuning width, and modulation depth.
  • The shape and sharpness of tuning curves are central to population coding theories.

Python Tutorial

How to create a tuning curve in Python

Use the full tutorial for implementation details, troubleshooting, and chart variations in matplotlib, seaborn, and plotly.

Complete Guide to Scientific Data Visualization

Example Visualization

Tuning curve showing mean firing rate with error bars plotted against stimulus orientation from 0 to 360 degrees with a fitted von Mises function

Create This Chart Now

Generate publication-ready tuning curves with AI in seconds. No coding required – just describe your data and let AI do the work.

View example prompt
Example AI Prompt

"Create a tuning curve from my data. Plot mean firing rate with SEM error bars at each stimulus value, fit a von Mises or Gaussian function to the data points, indicate the preferred stimulus with a dashed vertical line, and use publication-quality journal formatting."

How to create this chart in 30 seconds

1

Upload Data

Drag & drop your Excel or CSV file. Plotivy securely processes it in your browser.

2

AI Generation

Our AI analyzes your data and generates the Tuning Curve code automatically.

3

Customize & Export

Tweak the design with natural language, then export as high-res PNG, SVG or PDF.

Newsletter

Get one weekly tip for better tuning curves

Join researchers receiving concise Python plotting techniques to improve chart clarity and reduce revision cycles.

No spam. Unsubscribe anytime.

Python Code Example

example.py
import numpy as np
import matplotlib.pyplot as plt
from scipy.optimize import curve_fit

def gaussian(x, a, mu, sigma, c):
    return a * np.exp(-0.5 * ((x - mu) / sigma)**2) + c

angles = np.arange(0, 360, 20)
responses = gaussian(angles, 50, 180, 40, 10) + np.random.normal(0, 5, len(angles))

x_fit = np.linspace(0, 360, 100)
y_fit = gaussian(x_fit, 50, 180, 40, 10)

plt.figure(figsize=(10, 6))
plt.plot(angles, responses, 'ko', label='Data')
plt.plot(x_fit, y_fit, 'r-', linewidth=2, label='Gaussian Fit')
plt.title('Neuronal Tuning Curve', fontsize=14, fontweight='bold', pad=20)
plt.xlabel('Stimulus Angle (degrees)', fontsize=12)
plt.ylabel('Firing Rate (Hz)', fontsize=12)
plt.xticks(np.arange(0, 361, 90))
plt.legend()
plt.grid(alpha=0.3)
plt.tight_layout()
plt.savefig('plotivy-tuning-curve.png', dpi=150)
print("Tuning curve generated successfully.")

Opens the Analyze page with this code pre-loaded and ready to execute

Console Output

Output
Tuning curve generated successfully.

Common Use Cases

  • 1Quantifying orientation or direction selectivity in visual cortex neurons
  • 2Measuring frequency tuning in auditory cortex single-unit recordings
  • 3Characterising place field width of hippocampal place cells
  • 4Comparing tuning sharpness before and after pharmacological manipulation

Pro Tips

Include error bars (SEM or 95% CI) at each stimulus level to show trial variability

Fit a parametric function (Gaussian or von Mises) and overlay it on the data

For circular stimuli such as orientation, wrap the x-axis at 360 degrees or use a polar plot

Report the preferred stimulus and half-width at half-maximum (HWHM) in the figure caption

Long-tail keyword opportunities

how to create tuning curve in python
tuning curve matplotlib
tuning curve seaborn
tuning curve plotly
tuning curve scientific visualization
tuning curve publication figure python

High-intent chart variations

Tuning Curve with confidence interval overlays
Tuning Curve optimized for publication layouts
Tuning Curve with category-specific color encoding
Interactive Tuning Curve for exploratory analysis

Library comparison for this chart

matplotlib

Best when you need full control over axis formatting, annotation placement, and journal-specific styling for tuning-curve.

numpy

Useful in specialized workflows that complement core Python plotting libraries for tuning-curve analysis tasks.

scipy

Useful in specialized workflows that complement core Python plotting libraries for tuning-curve analysis tasks.

Free Cheat Sheet

Scientific Chart Selection Cheat Sheet

Not sure whether to use a Violin Plot, Box Plot, or Ridge Plot? Download our single-page reference mapping the most-used scientific chart types, exactly when to use them, and the core Matplotlib/Seaborn functions.

Comparison Charts
Distribution Charts
Time Series Data
Common Mistakes
No spam. Unsubscribe anytime.