Menu

Time Series
Static
37 Python scripts generated for candlestick chart this week

Candlestick Chart

Chart overview

Candlestick charts originated in 18th century Japan for rice trading and have become the standard for financial market visualization.

Key points

  • Each candlestick shows four price points: open, high, low, and close for a time period.
  • The 'body' represents the range between open and close, while 'wicks' extend to show high and low.
  • Green/white candles indicate price increases, while red/black show decreases.

Python Tutorial

How to create a candlestick chart in Python

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

How to Create a Bar Chart in Python

Example Visualization

Candlestick chart showing 30 days of stock price movements with volume

Create This Chart Now

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

View example prompt
Example AI Prompt

"Use mplfinance library to create a candlestick chart showing 'Open', 'High', 'Low', and 'Close' prices for the last 30 days. Generate a proper example dataset with realistic stock price movements."

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 Candlestick Chart 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 candlestick charts

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 pandas as pd
import mplfinance as mpf
import matplotlib.pyplot as plt
from datetime import datetime, timedelta

# Generate realistic OHLC data for the last 30 business days
np.random.seed(42)
dates = pd.date_range(end=datetime.today(), periods=30, freq='B')
price = 100 + np.cumsum(np.random.randn(30))  # random walk around 100

# Create Open, High, Low, Close columns
open_prices = price + np.random.randn(30) * 0.5
close_prices = price + np.random.randn(30) * 0.5
high_prices = np.maximum(open_prices, close_prices) + np.abs(np.random.randn(30) * 0.5)
low_prices = np.minimum(open_prices, close_prices) - np.abs(np.random.randn(30) * 0.5)

df = pd.DataFrame({
    'Open': open_prices,
    'High': high_prices,
    'Low': low_prices,
    'Close': close_prices
}, index=dates)

# Plot candlestick chart using mplfinance
fig, ax = mpf.plot(df, type='candle', style='charles',
                   title='Example Candlestick Chart (Last 30 Days)',
                   ylabel='Price ($)',
                   returnfig=True)

# Show the figure
plt.show()
# Add a simple moving average (10 & 20 days)
df['SMA10'] = df['Close'].rolling(window=10).mean()
df['SMA20'] = df['Close'].rolling(window=20).mean()

# Generate random volume data for demonstration
df['Volume'] = np.random.randint(1000, 5000, size=len(df))

# Re‑plot with volume and moving averages
mpf.plot(df,
         type='candle',
         style='charles',
         title='Candlestick Chart with Volume and SMA',
         ylabel='Price ($)',
         volume=True,
         mav=(10, 20),
         returnfig=False)

plt.show()
# END-OF-CODE

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

Common Use Cases

  • 1Stock and cryptocurrency price analysis
  • 2Forex trading visualization
  • 3Commodity price tracking
  • 4Technical pattern recognition

Pro Tips

Add moving averages (SMA, EMA) for trend identification

Include volume bars for confirmation of price movements

Use consistent color conventions (green=up, red=down)

Long-tail keyword opportunities

how to create candlestick chart in python
candlestick chart matplotlib
candlestick chart seaborn
candlestick chart plotly
candlestick chart scientific visualization
candlestick chart publication figure python

High-intent chart variations

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

Library comparison for this chart

mplfinance

Useful in specialized workflows that complement core Python plotting libraries for candlestick-chart analysis tasks.

plotly

Best for interactive hover, zoom, and web sharing when collaborators need to inspect values directly from candlestick-chart figures.

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.