Datasets API Reference¶
Built-in datasets for ggplotly, mirroring those available in ggplot2.
Loading Datasets¶
ggplotly.datasets.data(name=None)
¶
List available datasets or load a dataset by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | None
|
The name of the dataset to load (without .csv extension). If None, returns list of available datasets. Special case: 'us_flights' returns an igraph Graph object. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
|
If name is None: list of available dataset names. |
||
|
If name is 'us_flights': igraph.Graph object. |
||
Otherwise |
pandas.DataFrame containing the dataset. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the dataset name is not found. |
Examples:
Map Data¶
ggplotly.map_data.map_data(map_name='state')
¶
Get map region data for use with geom_map.
Similar to ggplot2's map_data() function, but returns region identifiers that work with Plotly's built-in geographic support.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
map_name
|
str
|
The map to retrieve. Options: - 'state': US state abbreviations - 'usa': Alias for 'state' - 'world': ISO-3 country codes - 'county': US county FIPS codes (placeholder) |
'state'
|
Returns:
| Type | Description |
|---|---|
|
pandas.DataFrame: A dataframe with region identifiers |
Examples:
Available Datasets¶
The following datasets are included with ggplotly:
| Dataset | Description |
|---|---|
mpg |
Fuel economy data for 234 cars (1999-2008) |
diamonds |
Prices and attributes of ~54,000 diamonds |
iris |
Classic Fisher's iris flower measurements |
mtcars |
Motor Trend car road tests (1974) |
economics |
US economic time series data |
economics_long |
Long format US economic time series |
midwest |
Midwest demographics data |
txhousing |
Texas housing market data |
faithfuld |
Old Faithful geyser eruption data (2D density) |
msleep |
Mammalian sleep data |
presidential |
US presidential terms |
seals |
Location data for seal movements |
commodity_prices |
Historical commodity price data |
luv_colours |
Color data in LUV color space |
us_flights |
US flight network (returns igraph Graph) |