Fundamentals 6 min read

Create Stunning Charts with Cufflinks in Minutes – A Python Visualization Guide

This article introduces the Python cufflinks library, showing how its simple DataFrame‑based API and built‑in themes let you create a variety of attractive charts—bar, line, scatter, bubble, subplots, box, histogram, and 3D—using just a few lines of code.

Python Crawling & Data Mining
Python Crawling & Data Mining
Python Crawling & Data Mining
Create Stunning Charts with Cufflinks in Minutes – A Python Visualization Guide

Previously I used matplotlib and pyecharts, but recently discovered cufflinks, a Python visualization library that combines simplicity with beautiful charts.

1. Simple Usage

The cufflinks library works with pandas DataFrames; the main plotting function is DataFrame.iplot. It accepts many parameters such as:

kind: chart type (scatter, pie, histogram, etc.)
mode: lines, markers, lines+markers
colors: trace colors
dash: line style (solid, dash, dashdot)
width: line width
xTitle: x‑axis label
yTitle: y‑axis label
title: chart title

Example of a bar chart:

import pandas as pd
import numpy as np
import cufflinks as cf
df = pd.DataFrame(np.random.rand(12, 4), columns=['a','b','c','d'])
df.iplot(kind='bar', title='Example', xTitle='X axis', yTitle='Y axis')

2. Beautiful Charts with Minimal Code

Cufflinks provides several themes (polar, pearl, henanigans, solar, ggplot, space, white) that style the charts.

Line Chart

cf.datagen.lines(4,10).iplot(mode='lines+markers', theme='solar')

Generating random data:

cf.datagen.lines(2,10)  # 2 groups, 10 points each

Scatter Chart

df = pd.DataFrame(np.random.rand(50,4), columns=['a','b','c','d'])
df.iplot(kind='scatter', mode='markers',
         colors=['orange','teal','blue','yellow'],
         size=20, theme='solar')

Bubble Chart

df.iplot(kind='bubble', x='a', y='b', size='c', theme='solar')

Subplots

df = cf.datagen.lines(4)
df.iplot(subplots=True, shape=(4,1), shared_xaxes=True,
         vertical_spacing=.02, fill=True, theme='ggplot')

Box Plot

cf.datagen.box(20).iplot(kind='box', legend=False, theme='ggplot')

Histogram

df.iloc[:,0:3].iplot(kind='histogram')

3D Chart

cf.datagen.scatter3d(5,4).iplot(kind='scatter3d',
                                 x='x', y='y', z='z',
                                 text='text', categories='categories')

Hope this introduction sparks your interest; cufflinks offers many more features to explore.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

PythonplotlychartingCufflinks
Python Crawling & Data Mining
Written by

Python Crawling & Data Mining

Life's short, I code in Python. This channel shares Python web crawling, data mining, analysis, processing, visualization, automated testing, DevOps, big data, AI, cloud computing, machine learning tools, resources, news, technical articles, tutorial videos and learning materials. Join us!

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.