> For the complete documentation index, see [llms.txt](https://docs.sdv.dev/sdv/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sdv.dev/sdv/evaluation/visualization.md).

# Visualization

Use these functions to visualize your actual data in 1 or 2-dimensional space. This can help you see what kind of patterns the synthetic data has learned, and identify differences between the real and synthetic data.

### get\_column\_plot

Use this function to visualize a real column against the same synthetic column. You can plot any column of type: `boolean`, `categorical`, `datetime` or `numerical`.&#x20;

```python
# for multi table data
from sdv.evaluation.multi_table import get_column_plot

# for single table data
# from sdv.evaluation.single_table import get_column_plot

fig = get_column_plot(
    real_data=real_data,
    synthetic_data=synthetic_data,
    metadata=metadata,
    table_name='guests',
    column_name='amenities_fee'
)
    
fig.show()
```

<figure><img src="/files/QlNJmDNdpfYwNwEvcQF6" alt=""><figcaption></figcaption></figure>

**Parameters**

* (required) `real_data`: The original training data. *For single table data, this is a pandas.DataFrame. For multi table data, this is a dictionary mapping each table name (string) to a pandas.DataFrame containing the data. (To skip plotting the real data, input `None`.)*
* (required) `synthetic_data`: Your synthetic data. *For single table data, this is a pandas.DataFrame. For multi table data, this is a dictionary mapping each table name (string) to a pandas.DataFrame containing the data.* *(To skip plotting the synthetic data, input `None`.)*
* (required) `metadata`: A [Metadata](/sdv/integration/metadata.md) object that describes the columns
* (required for multi table data) `table_name`: The name of the table
* (required) `column_name`: The name of the column you want to plot
* `plot_type`: The type of plot to create
  * (default) `None`: Determine an appropriate plot type based on your data type, as specified in the metadata.
  * `'bar'`: Plot the data as distinct bar graphs
  * `'displot'`: Plot the data as a smooth, continuous curves

**Output** A [plotly Figure](https://plotly.com/python-api-reference/generated/plotly.graph_objects.Figure.html) object that plots the distribution. This will change based on the sdtype.

{% hint style="info" %}
Use `fig.show()` to see the plot in an iPython notebook. The plot is interactive, allowing you to zoom, scroll and take screenshots.
{% endhint %}

### get\_column\_pair\_plot

Use this utility to visualize the trends between a pair of columns for real and synthetic data. You can plot any 2 columns of type: `boolean`, `categorical`, `datetime` or `numerical`. The columns do not have to the be the same type.

```python
# for multi table data
from sdv.evaluation.multi_table import get_column_pair_plot

# for single table data
# from sdv.evaluation.single_table import get_column_pair_plot

fig = get_column_pair_plot(
    real_data=real_data,
    synthetic_data=synthetic_data,
    metadata=metadata,
    table_name='guests',
    column_names=['room_rate', 'room_type'],
    )
    
fig.show()
```

**Parameters**

* (required) `real_data`: The original training data. *For single table data, this is a pandas.DataFrame. For multi table data, this is a dictionary mapping each table name (string) to a pandas.DataFrame containing the data. (To skip plotting the real data, input `None`.)*
* (required) `synthetic_data`: Your synthetic data. *For single table data, this is a pandas.DataFrame. For multi table data, this is a dictionary mapping each table name (string) to a pandas.DataFrame containing the data. (To skip plotting the synthetic data, input `None`.)*
* (required) `metadata`: A [Metadata](/sdv/integration/metadata.md) object that describes the columns
* (required for multi table data) `table_name`: The name of the table
* (required) `column_names`: A list with the names of the 2 columns you want to plot
* `plot_type`: The type of plot to create
  * (default) `None`: Determine an appropriate plot type based on your data type, as specified in the metadata.
  * `'box'`: Create a box plot showing the quartiles, broken down by different attributes
  * `'violin'`: Create a violin plot to show distributions, broken down by different attributes. This is an alternative to using `'box'`
  * `'heatmap'`: Create a side-by-side headmap showing the frequency of each pair of values
  * `'scatter'`: Create a scatter plot that plots each point on a 2D axis
* `sample_size`: The number of data points to plot
  * (default) `None`: Plot all the data points
  * `<integer>`: Subsample rows from both the real and synthetic data before plotting. Use this if you have a lot of data points.

**Output** A [plotly Figure](https://plotly.com/python-api-reference/generated/plotly.graph_objects.Figure.html) object that plots the 2D distribution. This will change based on the sdtype.

{% hint style="info" %}
Use `fig.show()` to see the plot in an iPython notebook. The plot is interactive, allowing you to zoom, scroll and take screenshots.
{% endhint %}

### get\_cardinality\_plot

Use this utility to visualize the cardinality of a multi-table relationship. The *cardinality* refers to the number of child rows that each parent row has. This could be 0 or more.

```python
# for multi table data
from sdv.evaluation.multi_table import get_cardinality_plot

fig = get_cardinality_plot(
    real_data=real_data,
    synthetic_data=synthetic_data,
    child_table_name='sessions',
    parent_table_name='users',
    child_foreign_key='user_id',
    metadata=metadata)
    
fig.show()
```

<figure><img src="/files/hVf6tPlMrwMWOSPLXUs0" alt=""><figcaption></figcaption></figure>

**Parameters**

* (required) `real_data`: The original training data. *This is a dictionary mapping each table name (string) to a pandas.DataFrame containing the data. (To skip plotting the real data, input `None`.)*
* (required) `synthetic_data`: Your synthetic data. *This is a dictionary mapping each table name (string) to a pandas.DataFrame containing the data. (To skip plotting the synthetic data, input `None`.)*
* (required) `child_table_name`: A string describing the name of the child table in the relationship
* (required) `parent_table_name`: A string describing the name of the parent table in the relationship
* (required) `child_foreign_key`: A string describing the name of the foreign key column of the child table that references the parent table
* (required) `metadata`:  A [Metadata](/sdv/integration/metadata.md) object that describes the data

**Output** A [plotly Figure](https://plotly.com/python-api-reference/generated/plotly.graph_objects.Figure.html) object that plots the cardinality of the real vs. the synthetic data for the provided relationship.

{% hint style="info" %}
Use `fig.show()` to see the plot in an iPython notebook. The plot is interactive, allowing you to zoom, scroll and take screenshots.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.sdv.dev/sdv/evaluation/visualization.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
