From 02185a0eaf4e9fa2bcf5126aa73a2915603072fc Mon Sep 17 00:00:00 2001 From: Mohammed Sadique Date: Mon, 10 Feb 2025 14:57:59 +0530 Subject: [PATCH 1/3] multi databar --- lib/matplotex/figure/areal/bar_chart.ex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/matplotex/figure/areal/bar_chart.ex b/lib/matplotex/figure/areal/bar_chart.ex index bf1fcc3..d87734e 100644 --- a/lib/matplotex/figure/areal/bar_chart.ex +++ b/lib/matplotex/figure/areal/bar_chart.ex @@ -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) From 9f8ca7d34286eb077687e56c7140959476d4ce4d Mon Sep 17 00:00:00 2001 From: Mohammed Sadique Date: Mon, 10 Feb 2025 16:07:48 +0530 Subject: [PATCH 2/3] version upate --- README.md | 2 +- mix.exs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index cfac201..77a978f 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ The package can be installed by adding **Matplotex** 0.4.6" } + {:matplotex, "~> 0.4.71" } ] ``` diff --git a/mix.exs b/mix.exs index 8b09896..828f625 100644 --- a/mix.exs +++ b/mix.exs @@ -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()), From 6436040e74b4e06129029ffd13f245f68cd1f934 Mon Sep 17 00:00:00 2001 From: Mohammed Sadique Date: Mon, 10 Feb 2025 16:24:23 +0530 Subject: [PATCH 3/3] doc correct --- lib/matplotex.ex | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/matplotex.ex b/lib/matplotex.ex index b6907f9..3720f77 100644 --- a/lib/matplotex.ex +++ b/lib/matplotex.ex @@ -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 @@ -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. @@ -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