> For the complete documentation index, see [llms.txt](https://jona-projects.gitbook.io/kiwicalc/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jona-projects.gitbook.io/kiwicalc/functions/visualization.md).

# Visualization

#### Plotting

You can plot Function objects with the `plot()` method. The plotting is done behind the scenes with the python library [matplotlib](broken://pages/pTRMHHLCs8F75wD3kRE1), as for this version. Functions with two variables\_dict will automatically be plotted in 3D space.

This is the signature of the plot method,  from kiwicalc's source code. You can see that all  of the parameters are **optional**.

```python
def plot(self, start: float = -10, end: float = 10, step: float = 0.01, ymin: float = -10, ymax: float = 10,
        others: "Optional[Iterable[Function]]" = None, show_axis=True, show=True):

                    
```

**Parameters:**

You can adjust the graph by modifying these settings:

| Name       | Type  | Default Value | Meaning                                                             |
| ---------- | ----- | ------------- | ------------------------------------------------------------------- |
| start      | float | \`-10\`       | The \`x\` value that plotting starts from                           |
| end        | float | \`10\`        | The \`x\` value in which the plotting ends                          |
| step       | float | \`0.05\`      | The distance between each computed point in the \`x\` axis          |
| ymin       | float | \`-10\`       | The lowest y value that is shown (without scrolling down the graph) |
| ymax       | float | \`10\`        | The highest y value that is shown (without scrolling up the graph)  |
| show\_axis | True  | True          | Whether to draw an axis system along with the graph, or not         |
| show       | True  | True          | Whether to show the graph or not.                                   |

* **start**: type float, the number to start plotting from. Default value is -10.
* **end**: type float, Plotting from start to end
* **step**:type float, the interval between each dot in the graph. Default value is 0.01.
* **scatter**: type bool, if set to True, the graph will be scattered and not plotted. Default value: False
* **ymin**: type float, the minimum value of y in the graph's perspective.<br>
* **ymax**: type float, the maximum value of y in the graph's perspective.
* **others**: other functions that you wish to plot together with the current function
* **show\_axis**: whether to show the axis or not
* **show** - whether to show the graph, or not

For example, lets plot the function $$f(x) = x^2$$ when $$-10 \le x \le 10$$. Let's also customize the interval between each x value to $$0.1$$ by setting the step parameter. Smaller distances between each dot will result in better accuracy of the function, but it will also take more time.

```python
# Plotting ( via matplotlib )
fn = Function("f(x) = x^2")
fn.plot(start=-10, stop=10, step=0.1)
                
```

You can also define and plot some more sophisticated and versatile functions. For example, lets plot the function $$f(x) = x e^{\sin(x)} - 3 \ln \left| 4x \right|$$

```python
# Plotting ( via matplotlib )
example_function = Function("f(x)=xe^sin(x)-3ln(|4x|)")
example_function.plot(start=-10, stop=10)
                    
```

#### Scattering

You can scatter functions via the `scatter()`, `scatter2d()` and `scatter3d()` methods. The scatter method is basically a wrapper that chooses whether to use the `scatter2d()` method or the `scatter3d()` method, depending on the number of variables.

&#x20;If you already know whether to scatter in 2d or 3d, you should use the `scatter2d()` and `scatter3d()` methods, as they are more explicit and offer more parameters. Here are the signatures of the three methods, directly from the kiwicalc source code.

```python
def scatter(self, start: float = -15, end: float = 15, step: float = 0.1, ymin=-15, ymax=15, show_axis=True,show=True):
                    
```

```python
def scatter2d(self, start: float = -15, stop: float = 15, step: float = 0.3, ymin=-15, ymax=15, show_axis=True,
                    show=True, basic=True):
                    
```

```python
def scatter3d(self, start: float = -3, stop: float = 3,
              step: float = 0.3,
              xlabel: str = "X Values",
              ylabel: str = "Y Values", zlabel: str = "Z Values", show=True, fig=None, ax=None,
              write_labels=True, meshgrid=None, title=""):
                    
```

For example:

```python
fn = Function("f(x) = x^2")
fn.scatter2d()
                    
```

```python
fn1 = Function("f(x,y) = sin(x) * cos(y)")
fn1.scatter3d()
                    
```

Additional Experimental Feature: If the `basic` parameter in the `scatter2d()` is set to `False`, the points will contain labels. This may be more convenient, but it's also slower. For instance:

```python
fn2 = Function("f(x) = x^2")
fn2.scatter2d(basic=False)
```
