Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ The package can be installed by adding <font color="darkblue"> **Matplotex**</fo
```elixir
def deps do
[
{:matplotex, "~> 0.4.6" }
{:matplotex, "~> 0.4.71" }
]
```

Expand Down
12 changes: 9 additions & 3 deletions lib/matplotex.ex
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ defmodule Matplotex do
Generates a bar chart using the provided values and bar widths.

## Parameters

- `values` (list of numbers): A list of numerical values representing the heights of the bars in the chart.
- `width` (floatiung point number): The width of each bar in inches.
- `opts` (keyword list): It will support all opts mentioned above, some bar specific options are there those are
Expand Down Expand Up @@ -226,6 +225,11 @@ defmodule Matplotex do
## Parameters

- `figure` (%Figure{}): The figure to which the new dataset will be added.
- `pos` (floating point number) : In multi-dataset plots, the bar position is determined by a numerical offset.
- Positive values shift the bar to the right of the tick.
- Negative values shift the bar to the left of the tick.
- Zero keeps the bar centered on the tick.
This allows precise alignment and spacing between multiple datasets in a bar chart
- `values` (list): A list of numerical values representing the heights of the bars in the new dataset.
- `width` (float): The width of the bars in the dataset.
- `opts` (keyword list, optional): A set of options for customizing the appearance of the new dataset, such as color and label.
Expand All @@ -240,10 +244,12 @@ defmodule Matplotex do
categories = ["apple", "banana", "fig", "avocado"]
values1 = [22, 33, 28, 34]
values2 = [53, 63, 59, 60]
values3 = [53, 63, 59, 60]
width = 0.22

Matplotex.bar(width, values1, width, label: "Dataset1", color: "#255199")
|> M.bar(width, values2, width, label: "Dataset2", color: "#D3D3D3")
Matplotex.bar(-width, values1, width, label: "Dataset1", color: "#255199")
|> M.bar(0, values2, width, label: "Dataset2", color: "#D3D3D3")
|> M.bar(width, values2, width, label: "Dataset3", color: "green")
"""
def bar(%Figure{} = figure, pos, values, width, opts) do
figure
Expand Down
4 changes: 2 additions & 2 deletions lib/matplotex/figure/areal/bar_chart.ex
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,11 @@ defmodule Matplotex.Figure.Areal.BarChart do
@xmin_value |> Nx.linspace(nof_x, n: nof_x) |> Nx.to_list()
end

defp bar_position(x, pos_factor) when pos_factor < 0 do
defp bar_position(x, pos_factor) do
x + pos_factor
end

defp bar_position(x, _pos_factor), do: x


defp list_of_ticks(data, step) do
1..length(data)
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ defmodule Matplotex.MixProject do
[
app: :matplotex,
organization: :bigthinkcode,
version: "0.4.7",
version: "0.4.71",
elixir: "~> 1.17",
start_permanent: Mix.env() == :prod,
elixirc_paths: elixirc_paths(Mix.env()),
Expand Down