Skip to content

Commit 48c8d12

Browse files
author
Mohammed Sadique
committed
format
1 parent 9ffb588 commit 48c8d12

4 files changed

Lines changed: 19 additions & 19 deletions

File tree

lib/matplotex/figure/areal/plot_options.ex

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ defmodule Matplotex.Figure.Areal.PlotOptions do
101101

102102
@spec set_options_in_figure(Figure.t(), keyword()) :: Figure.t()
103103
def set_options_in_figure(%Figure{} = figure, opts) do
104-
105104
figure
106105
|> cast_figure(opts)
107106
|> cast_axes(opts)
@@ -114,9 +113,12 @@ defmodule Matplotex.Figure.Areal.PlotOptions do
114113

115114
defp cast_axes(%Figure{axes: axes} = figure, opts) do
116115
opts = Keyword.delete(opts, :label)
117-
%Figure{figure | axes: axes |> struct(opts) |> cast_two_d_structs(opts)
118-
# |>fulfill_tick_and_lim()
119-
}
116+
117+
%Figure{
118+
figure
119+
| axes: axes |> struct(opts) |> cast_two_d_structs(opts)
120+
# |>fulfill_tick_and_lim()
121+
}
120122
end
121123

122124
# defp fulfill_tick_and_lim(%{tick: nil, limit: nil} = axes) do
@@ -125,7 +127,6 @@ defmodule Matplotex.Figure.Areal.PlotOptions do
125127

126128
defp cast_two_d_structs(%{label: label, tick: tick, limit: limit} = axes, opts)
127129
when is_map(opts) do
128-
129130
%{
130131
axes
131132
| label: TwoD.update(label, opts, :label),

lib/matplotex/figure/lead.ex

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,9 @@ defmodule Matplotex.Figure.Lead do
6464
} = axes
6565
} = figure
6666
) do
67-
68-
6967
{x_ticks, x_lim} = maybe_generate_ticks(x_ticks, x_lim, x_data, width)
7068
{y_ticks, y_lim} = maybe_generate_ticks(y_ticks, y_lim, y_data, height)
69+
7170
%Figure{
7271
figure
7372
| axes: %{
@@ -79,37 +78,38 @@ defmodule Matplotex.Figure.Lead do
7978
end
8079

8180
defp maybe_generate_ticks(ticks, limit, data, number_of_ticks) do
82-
8381
cond do
8482
is_nil(ticks) || length(ticks) < 3 ->
8583
generate_ticks(limit, data, ceil(number_of_ticks))
84+
8685
is_nil(limit) ->
8786
{ticks, generate_limit(data)}
87+
8888
true ->
8989
{ticks, limit}
90-
9190
end
9291
end
9392

9493
defp generate_ticks(nil, data, number_of_ticks) do
9594
data
96-
|>generate_limit()
97-
|>generate_ticks(data, number_of_ticks)
95+
|> generate_limit()
96+
|> generate_ticks(data, number_of_ticks)
9897
end
9998

100-
10199
defp generate_ticks({lower_limit, upper_limit} = lim, _data, number_of_ticks) do
102100
{lower_limit |> Nx.linspace(upper_limit, n: number_of_ticks) |> Nx.to_list(), lim}
103101
end
104102

105103
defp generate_limit(data) do
106104
{min, upper_limit} = Enum.min_max(data)
105+
107106
lower_limit =
108107
if min < 0 do
109108
min
110109
else
111110
0
112111
end
112+
113113
{lower_limit, upper_limit}
114114
end
115115

@@ -364,12 +364,11 @@ defmodule Matplotex.Figure.Lead do
364364
rotation: 0
365365
},
366366
text
367-
)
368-
do
369-
text_size = tick_length(text) * to_number(font_size) * (pt_to_inch_ratio / 2)
370-
offset_for_text_length = ((1/tick_length(text)) * (pt_to_inch_ratio/2) * to_number(font_size))
371-
text_size + offset_for_text_length + flate
372-
end
367+
) do
368+
text_size = tick_length(text) * to_number(font_size) * (pt_to_inch_ratio / 2)
369+
offset_for_text_length = 1 / tick_length(text) * (pt_to_inch_ratio / 2) * to_number(font_size)
370+
text_size + offset_for_text_length + flate
371+
end
373372

374373
def length_required_for_text(
375374
%Font{

lib/matplotex/figure/sketch.ex

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ defmodule Matplotex.Figure.Sketch do
33
@dpi 96
44

55
def call({stream, %Figure{figsize: {width, height}}}) do
6-
76
stream
87
|> Stream.map(fn %module{} = elem ->
98
elem = module.flipy(elem, height)

lib/matplotex/figure/two_d.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ defmodule Matplotex.Figure.TwoD do
88
y: fetch_from_opts(opts, :y, context)
99
}
1010
end
11+
1112
defp fetch_from_opts(opts, key, context) do
1213
Map.get(opts, :"#{key}_#{context}")
1314
end

0 commit comments

Comments
 (0)