# 2. Concepts

<figure><img src="https://29846817-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fw6gfR46YgOL1YsdZtqqx%2Fuploads%2Fo1YrueB9LPmTLpFY6Nch%2Fgrid.png?alt=media&#x26;token=418ab99d-fcef-446f-b2f4-19bf25487dd2" alt=""><figcaption></figcaption></figure>

### Data Source

Ezel's APIs expect `polars::frame::DataFrame` as a data source.

If you have other data types, they should be converted to `DataFrame` first.

```rust
use ezel::prelude::*;
use polars::prelude::*;

let mut x = vec![..];
let mut y = vec![..];

let df = df!(
    "x" => &x,
    "y" => &y
)
.unwrap();

let mut plot = Cartesian2::default();
plot.scatter(df, Column("x".to_string()), Column("y".to_string()));
```

More ergonomic interfaces are planned to be added.

```
let x: Vec<f64>;
let y: Vec<f64>;

ezel::quick::scatter_xy(x, y); // Cartesian2 + x + y

let mut plot = Cartesian2::default();
plot.scatter_xy(x, y); // two Vec<f64>
```

### Data Types (i64, f64, ..)

`f64` are expected in most places. If you have `f32` data, simply convert it to `f64`.

### Composition

Ezel borrows the idea of protrusion from `Makie.jl`. The main areas of items in the grid are aligned by rows and columns.

### Composition

TODO

### Protrusion

TODO

### Attribute

Attributes are the properties of plots such as marker size, color, etc.

There are 3 types of attribute value: a const, categorical column, or scalar column.

```rust
marker_size: ConstOrScalar<f64>, // const or scalar
marker_shape: ConstOrCategorical<MarkerShape>, // const or categorical
marker_color: ConstOrColumn<Color>, // const or categorical or scalar
```

* `scatter.marker.size = Const(10.0)` means all markers have the same size 10.0.
* `scatter.marker.shape =` `Column("species".to_string())`assigns to each species a marker shape from the theme's shape cycle (e.g. [🟢](https://whatemoji.org/green-circle/)->[**🟩** ](https://whatemoji.org/green-square/)->[💚](https://whatemoji.org/green-heart/)-> ..).
* `scatter.marker.color = Column("column_name".to_string())`uses a color from the current color cycle ([🟢](https://whatemoji.org/green-circle/)->[🟡](https://whatemoji.org/yellow-circle/)->[🟤](https://whatemoji.org/brown-circle/)->[🔴](https://whatemoji.org/red-circle/)->..) if the column is categorical or string. Otherwise it uses a color from the current color map (![](https://29846817-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fw6gfR46YgOL1YsdZtqqx%2Fuploads%2F0CRVzQ66VkRJHmEEEo51%2Fimage.png?alt=media\&token=001d87a2-206e-496d-9ca0-dce1cc9dcf35))

If you want to use a f64 column in polars' DataFrame as categorical data, the easiest way is to cast it to the string dtype.

<br>


---

# Agent Instructions: 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:

```
GET https://ezel.rustic.dev/basics/2.-concepts.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
