6 module function pd2d_get_axes_cmd(this) result(x)
8 class(plot_data_2d),
intent(in) :: this
9 character(len = :),
allocatable :: x
12 if (this%get_draw_against_y2())
then
20 module function pd2d_get_data_cmd(this) result(x)
22 class(plot_data_2d),
intent(in) :: this
23 character(len = :),
allocatable :: x
26 type(string_builder) :: str
28 character :: delimiter, nl
29 real(real64),
allocatable,
dimension(:) :: xv, yv, cv, ps
30 real(real64),
allocatable,
dimension(:,:) :: pts
31 real(real64) :: tol, maxy, miny, eps
32 logical :: usecolors, usevarpoints
38 usecolors = this%get_use_data_dependent_colors()
39 usevarpoints = this%get_use_variable_size_points()
42 xv = this%get_x_data()
43 yv = this%get_y_data()
44 if (usecolors .and. usevarpoints)
then
45 cv = this%get_color_data()
46 ps = this%get_point_size_data()
48 call str%append(to_string(xv(i)))
49 call str%append(delimiter)
50 call str%append(to_string(yv(i)))
51 call str%append(delimiter)
52 call str%append(to_string(ps(i)))
53 call str%append(delimiter)
54 call str%append(to_string(cv(i)))
57 else if (usecolors .and. .not.usevarpoints)
then
58 cv = this%get_color_data()
60 call str%append(to_string(xv(i)))
61 call str%append(delimiter)
62 call str%append(to_string(yv(i)))
63 call str%append(delimiter)
64 call str%append(to_string(cv(i)))
67 else if (.not.usecolors .and. usevarpoints)
then
68 ps = this%get_point_size_data()
70 call str%append(to_string(xv(i)))
71 call str%append(delimiter)
72 call str%append(to_string(yv(i)))
73 call str%append(delimiter)
74 call str%append(to_string(ps(i)))
78 if (this%get_simplify_data())
then
81 tol = abs(this%get_simplification_factor() * (maxy - miny))
82 eps = 10.0d0 * epsilon(eps)
83 if (tol < eps) tol = eps
84 pts = simplify_polyline(xv, yv, tol)
85 do i = 1,
size(pts, 1)
86 call str%append(to_string(pts(i,1)))
87 call str%append(delimiter)
88 call str%append(to_string(pts(i,2)))
93 call str%append(to_string(xv(i)))
94 call str%append(delimiter)
95 call str%append(to_string(yv(i)))
102 x = char(str%to_string())
106 pure module function pd2d_get_data_count(this) result(x)
107 class(plot_data_2d),
intent(in) :: this
109 if (
allocated(this%m_data))
then
110 x =
size(this%m_data, 1)
117 pure module function pd2d_get_x_data(this, index) result(x)
118 class(plot_data_2d),
intent(in) :: this
119 integer(int32),
intent(in) :: index
121 if (
allocated(this%m_data))
then
122 x = this%m_data(index, 1)
129 module subroutine pd2d_set_x_data(this, index, x)
130 class(plot_data_2d),
intent(inout) :: this
131 integer(int32),
intent(in) :: index
132 real(real64),
intent(in) :: x
133 if (
allocated(this%m_data))
then
134 this%m_data(index, 1) = x
139 pure module function pd2d_get_y_data(this, index) result(x)
140 class(plot_data_2d),
intent(in) :: this
141 integer(int32),
intent(in) :: index
143 if (
allocated(this%m_data))
then
144 x = this%m_data(index, 2)
151 module subroutine pd2d_set_y_data(this, index, x)
152 class(plot_data_2d),
intent(inout) :: this
153 integer(int32),
intent(in) :: index
154 real(real64),
intent(in) :: x
155 if (
allocated(this%m_data))
then
156 this%m_data(index, 2) = x
161 module subroutine pd2d_set_data_1(this, x, y, c, ps, err)
163 class(plot_data_2d),
intent(inout) :: this
164 real(real64),
intent(in),
dimension(:) :: x, y
165 real(real64),
intent(in),
dimension(:),
optional :: c, ps
166 class(errors),
intent(inout),
optional,
target :: err
169 integer(int32) :: i, n, flag, ncols
170 class(errors),
pointer :: errmgr
171 type(errors),
target :: deferr
176 if (
present(c)) ncols = ncols + 1
177 if (
present(ps)) ncols = ncols + 1
178 if (
present(err))
then
185 if (
size(y) /= n)
then
186 call errmgr%report_error(
"pd2d_set_data_1", &
187 "The input arrays are not the same size.", &
188 plot_array_size_mismatch_error)
192 if (
size(c) /= n)
then
193 call errmgr%report_error(
"pd2d_set_data_1", &
194 "The input arrays are not the same size.", &
195 plot_array_size_mismatch_error)
199 if (
present(ps))
then
200 if (
size(ps) /= n)
then
201 call errmgr%report_error(
"pd2d_set_data_1", &
202 "The input arrays are not the same size.", &
203 plot_array_size_mismatch_error)
209 if (
allocated(this%m_data))
deallocate(this%m_data)
210 allocate(this%m_data(n, ncols), stat = flag)
212 call errmgr%report_error(
"pd2d_set_data_1", &
213 "Insufficient memory available.", plot_out_of_memory_error)
230 if (
present(c) .and.
present(ps))
then
231 call this%set_use_data_dependent_colors(.true.)
232 call this%set_use_variable_size_points(.true.)
233 do concurrent(i = 1:n)
234 this%m_data(i, 1) = x(i)
235 this%m_data(i, 2) = y(i)
236 this%m_data(i, 3) = ps(i)
237 this%m_data(i, 4) = c(i)
239 else if (
present(c) .and. .not.
present(ps))
then
240 call this%set_use_data_dependent_colors(.true.)
241 call this%set_use_variable_size_points(.false.)
242 do concurrent(i = 1:n)
243 this%m_data(i, 1) = x(i)
244 this%m_data(i, 2) = y(i)
245 this%m_data(i, 3) = c(i)
247 else if (.not.
present(c) .and.
present(ps))
then
248 call this%set_use_data_dependent_colors(.false.)
249 call this%set_use_variable_size_points(.true.)
250 do concurrent(i = 1:n)
251 this%m_data(i, 1) = x(i)
252 this%m_data(i, 2) = y(i)
253 this%m_data(i, 3) = ps(i)
256 call this%set_use_data_dependent_colors(.false.)
257 call this%set_use_variable_size_points(.false.)
258 do concurrent(i = 1:n)
259 this%m_data(i, 1) = x(i)
260 this%m_data(i, 2) = y(i)
266 pure module function pd2d_get_draw_against_y2(this) result(x)
267 class(plot_data_2d),
intent(in) :: this
273 module subroutine pd2d_set_draw_against_y2(this, x)
274 class(plot_data_2d),
intent(inout) :: this
275 logical,
intent(in) :: x
280 module subroutine pd2d_set_data_2(this, y, err)
282 class(plot_data_2d),
intent(inout) :: this
283 real(real64),
intent(in),
dimension(:) :: y
284 class(errors),
intent(inout),
optional,
target :: err
287 integer(int32) :: i, n, flag
288 class(errors),
pointer :: errmgr
289 type(errors),
target :: deferr
293 if (
present(err))
then
300 if (
allocated(this%m_data))
deallocate(this%m_data)
301 allocate(this%m_data(n, 2), stat = flag)
303 call errmgr%report_error(
"pd2d_set_data_2", &
304 "Insufficient memory available.", plot_out_of_memory_error)
307 do concurrent(i = 1:n)
308 this%m_data(i, 1) = real(i, real64)
309 this%m_data(i, 2) = y(i)
314 module function pd2d_get_x_array(this) result(x)
316 class(plot_data_2d),
intent(in) :: this
317 real(real64),
allocatable,
dimension(:) :: x
320 if (
allocated(this%m_data))
then
326 module function pd2d_get_y_array(this) result(x)
328 class(plot_data_2d),
intent(in) :: this
329 real(real64),
allocatable,
dimension(:) :: x
332 if (
allocated(this%m_data))
then
340 module function pd2d_get_c_array(this) result(x)
342 class(plot_data_2d),
intent(in) :: this
343 real(real64),
allocatable,
dimension(:) :: x
346 if (
allocated(this%m_data))
then
347 if (
size(this%m_data, 2) == 3)
then
349 else if (
size(this%m_data, 2) == 4)
then
358 module function pd2d_get_ps_array(this) result(x)
360 class(plot_data_2d),
intent(in) :: this
361 real(real64),
allocatable,
dimension(:) :: x
364 if (
allocated(this%m_data))
then
365 if (
size(this%m_data, 2) > 2)
then