Bugfix/correct plotting - #54
Conversation
77ea70c to
8af5f76
Compare
…/geolib-plus into bugfix/correct_plotting
| if not (x_axis_type == "primary"): | ||
| vertical_rel_spacing += extra_label_spacing | ||
| vertical_rel_spacing += ( | ||
| extra_label_spacing * CALIBRATED_LENGTH_FIGURE_SIZE / (ylim[0] - ylim[1]) |
There was a problem hiding this comment.
added as the spacing is also relative to the size of the whole figure
|
The old approach used settings["secondary_top_axis_position"]], which:
I changed the code so that it is automatic and not dependent on the input of the user. Spine sits above the multicolor labels and bellow the text box. |
anoordam
left a comment
There was a problem hiding this comment.
the predrilled depth text box is at a wrong position i think
| vertical_rel_spacing = ( | ||
| LABEL_VERTICAL_SPACING_RATIO * CALIBRATED_LENGTH_FIGURE_SIZE / (ylim[0] - ylim[1]) | ||
| ) | ||
| if not (x_axis_type == "primary"): | ||
| vertical_rel_spacing += extra_label_spacing | ||
| vertical_rel_spacing += ( | ||
| extra_label_spacing * CALIBRATED_LENGTH_FIGURE_SIZE / (ylim[0] - ylim[1]) |
There was a problem hiding this comment.
CALIBRATED_LENGTH_FIGURE_SIZE / (ylim[0] - ylim[1]) can be made a 1 variable
| :param ylim: vertical limit [y_max, y_min] | ||
| :param extra_label_spacing: extra spacing for secondary axes | ||
| :return: position of top spine in axes coordinates | ||
| """ | ||
| y_min = ylim[1] | ||
| y_max = ylim[0] |
There was a problem hiding this comment.
i think its more standard to have [ymin, ymax] in the ylim, instead of [ymax,ymin]
There was a problem hiding this comment.
or if it requires a whole refactr of the code I wouldnt change it, as it is not that important
There was a problem hiding this comment.
This requires a lot of changes, originally it is set in the function get_y_lims. Although normally it should be [ymin, ymax] in this case the [ymax,ymin] makes sense for plotting since the y axis is defined from ymax to ymin. I will not take any actions here
| # Calculate the vertical spacing used for multicolor labels | ||
| # From set_multicolor_label: vertical_rel_spacing = 0.06 * CALIBRATED_LENGTH_FIGURE_SIZE / y_range | ||
| # Plus extra spacing for secondary axes: extra_label_spacing * CALIBRATED_LENGTH_FIGURE_SIZE / y_range | ||
| # CALIBRATED_LENGTH_FIGURE_SIZE = 21 meters | ||
| # extra_label_spacing = 0.02 |
There was a problem hiding this comment.
i think this comment can go to the docstring at the top of this function
| ) | ||
|
|
||
| return ax | ||
| return None |
There was a problem hiding this comment.
| return None |
|
|
||
| # Vertical length of the graph in meter | ||
| # cpt.plot_settings.vertical_settings["length_graph"] = 50 |
There was a problem hiding this comment.
| # Vertical length of the graph in meter | |
| # cpt.plot_settings.vertical_settings["length_graph"] = 50 |
There was a problem hiding this comment.
are these changes required?
There was a problem hiding this comment.
yes! Otherwise the tests fail in the actions
| assert result == pytest.approx(expected) | ||
| assert result == pytest.approx(1.0336) # For 50m range |
There was a problem hiding this comment.
you assert the same thing twice
| assert self.are_plots_identical( | ||
| generated_path, reference_path | ||
| ), f"Generated plot for {cpt_file_xml.name} does not match reference." | ||
| #assert self.are_plots_identical( |
There was a problem hiding this comment.
why do you comment this check?
| if np.any(diff): | ||
| return True | ||
| return False |
There was a problem hiding this comment.
| if np.any(diff): | |
| return True | |
| return False | |
| return np.any(diff) |
|



When we generate the plot cpts as "unlimited," i.e., not on A4, we notice that the scale bar at the top of the sounding jumps in some cases.