Skip to content

Commit 9aeb9bf

Browse files
Add example
1 parent e332c11 commit 9aeb9bf

2 files changed

Lines changed: 42 additions & 1 deletion

File tree

examples/CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
find_package(fstring QUIET)
2+
13
# Example 1
24
add_executable(generic_2d_plot generic_2d_plot.f90)
35
target_link_libraries(generic_2d_plot fplot)
@@ -147,6 +149,10 @@ target_link_libraries(correlation_plot_example fplot)
147149
add_executable(margins_example margins_example.f90)
148150
target_link_libraries(margins_example fplot)
149151

152+
# Example 38
153+
add_executable(box_whisker_example box_whisker_example.f90)
154+
target_link_libraries(box_whisker_example fplot fstring::fstring)
155+
150156
if (${BUILD_SHARED_LIBS} AND WIN32)
151157
add_custom_command(
152158
TARGET generic_2d_plot
@@ -156,4 +162,4 @@ if (${BUILD_SHARED_LIBS} AND WIN32)
156162
$<TARGET_FILE_DIR:generic_2d_plot>
157163
COMMAND_EXPAND_LISTS
158164
)
159-
endif()
165+
endif()

examples/box_whisker_example.f90

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
program example
2+
use iso_fortran_env
3+
use fplot_core
4+
use strings
5+
implicit none
6+
7+
! Variables
8+
integer(int32), parameter :: n = 5
9+
integer(int32) :: i
10+
type(string) :: titles(n)
11+
real(real64) :: boxmin(n), boxmax(n), whiskermin(n), whiskermax(n)
12+
type(plot_2d) :: plt
13+
type(plot_data_box_whisker) :: pd
14+
15+
! Initialization
16+
do i = 1, n
17+
titles(i) = "Item " // to_string(i)
18+
end do
19+
call random_number(whiskermin)
20+
call random_number(whiskermax)
21+
call random_number(boxmin)
22+
call random_number(boxmax)
23+
24+
! Ensure proper order
25+
boxmin = boxmin + whiskermin
26+
boxmax = boxmin + boxmax
27+
whiskermax = whiskermax + boxmax
28+
29+
! Create the plot
30+
call plt%initialize()
31+
32+
call pd%define_data(titles, boxmin, boxmax, whiskermin, whiskermax)
33+
call plt%push(pd)
34+
call plt%draw()
35+
end program

0 commit comments

Comments
 (0)