Skip to content

Commit 1af4e69

Browse files
Add box and whisker functionality
1 parent c8b6fb4 commit 1af4e69

3 files changed

Lines changed: 15 additions & 1 deletion

File tree

examples/box_whisker_example.f90

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ program example
1111
real(real64) :: boxmin(n), boxmax(n), whiskermin(n), whiskermax(n)
1212
type(plot_2d) :: plt
1313
type(plot_data_box_whisker) :: pd
14+
class(plot_axis), pointer :: xAxis
1415

1516
! Initialization
1617
do i = 1, n
17-
titles(i) = "Item-" // to_string(i)
18+
titles(i) = '"' // "Item " // to_string(i) // '"'
1819
end do
1920
boxmin = [4.5d0, 5.0d0, 6.0d0]
2021
boxmax = [7.5d0, 8.0d0, 9.0d0]
@@ -23,9 +24,14 @@ program example
2324

2425
! Create the plot
2526
call plt%initialize()
27+
xAxis => plt%get_x_axis()
28+
call xAxis%set_autoscale(.false.)
29+
call xAxis%set_limits(0.0d0, n + 1.0d0)
2630

2731
call pd%define_data(titles, boxmin, boxmax, whiskermin, whiskermax)
2832
call pd%set_line_width(2.0)
33+
call pd%set_box_fill_opacity(0.5)
34+
call pd%set_box_width(0.1)
2935
call plt%push(pd)
3036
call plt%draw()
3137
end program

src/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ set(FPLOT_SOURCES ${FPLOT_SOURCES} PARENT_SCOPE)
4848

4949
# Dependencies
5050
include(FetchContent)
51+
find_package(OpenMP REQUIRED COMPONENTS Fortran)
5152
find_package(ferror QUIET)
5253
find_package(collections QUIET)
5354
find_package(geompack QUIET)
@@ -134,6 +135,11 @@ target_link_libraries(
134135
$<BUILD_INTERFACE:forcolormap>
135136
)
136137

138+
if (OpenMP_Fortran_FOUND)
139+
target_link_libraries(${PROJECT_NAME} PRIVATE OpenMP::OpenMP_Fortran)
140+
target_compile_definitions(${PROJECT_NAME} PRIVATE USEOPENMP=1)
141+
endif()
142+
137143
set_target_properties(
138144
${PROJECT_NAME}
139145
PROPERTIES

src/fplot_plot_data_box_whisker.f90

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ module fplot_plot_data_box_whisker
3535
!! Fill the boxes?
3636
real(real32), private :: m_boxOpacity = 1.0
3737
!! Box opacity [0, 1.0].
38+
logical, private :: m_drawBorder = .true.
39+
!! Draw the box border?
3840
contains
3941
procedure, public :: define_data => pdbw_define_data_xstring
4042
procedure, public :: get_command_string => pdbw_get_cmd

0 commit comments

Comments
 (0)