Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An issue with the legend when drawing a box plot #52

Open
brandfucker opened this issue Mar 2, 2023 · 4 comments
Open

An issue with the legend when drawing a box plot #52

brandfucker opened this issue Mar 2, 2023 · 4 comments

Comments

@brandfucker
Copy link

when i was running your example ,some result PDF in plots/traj_est such as the rel_translation_err has something wrong. The legend did not displayed correctly.
屏幕截图 2023-03-02 184616
屏幕截图 2023-03-02 184656

@QiuYue-bit
Copy link

i solve this problem by using the release version

@yao-hexiong
Copy link

i solve this problem by using the release version

I have the same problem. Can you explain it in detail?

@setareh-soltanieh
Copy link

Hi, can you tell me how are you capturing these results? I have recorded the ground truth and the estimated poses in a txt file with the correct format but my results are as follows:

======================================
Absolute Trajectory Error

rmse_ori = 178.702 | rmse_pos = 0.103
mean_ori = 178.701 | mean_pos = 0.097
min_ori = 176.714 | min_pos = 0.016
max_ori = 179.984 | max_pos = 0.173
std_ori = 0.547 | std_pos = 0.037

Relative Pose Error

seg 8 - median_ori = 143.450 | median_pos = 4.591 (2383 samples)
seg 16 - median_ori = 88.770 | median_pos = 3.702 (2082 samples)
seg 24 - median_ori = 92.984 | median_pos = 3.481 (1816 samples)
seg 32 - median_ori = 85.973 | median_pos = 3.481 (1427 samples)
seg 40 - median_ori = 138.841 | median_pos = 3.082 (1099 samples)

@hyq123-cmd
Copy link

I have solved this bug by modifying the below code block like this:
the original code block:

def plot_odometry_error_per_dataset(dataset_rel_err, dataset_names, algorithm_names,
                                    datasets_outdir, plot_settings):
    for dataset_idx, dataset_nm in enumerate(dataset_names):
        output_dir = datasets_outdir[dataset_nm]
        print("Plotting {0}...".format(dataset_nm))
        rel_err = dataset_rel_err[dataset_idx]
        assert sorted(algorithm_names) == sorted(list(rel_err['trans_err'].keys()))
        distances = rel_err['subtraj_len']

        config_labels = []
        config_colors = []
        for v in algorithm_names:
            config_labels.append(plot_settings['algo_labels'][v])
            config_colors.append(plot_settings['algo_colors'][v])

        fig = plt.figure(figsize=(12, 3))
        ax = fig.add_subplot(
            121, xlabel='Distance traveled (m)',
            ylabel='Translation error (\%)')
        pu.boxplot_compare(ax, distances, [rel_err['trans_err_perc'][v] for v in algorithm_names],
                           config_labels, config_colors, legend=True)
        ax = fig.add_subplot(
            122, xlabel='Distance traveled (m)', ylabel='Rotation error (deg / m)')
        pu.boxplot_compare(ax, distances, [rel_err['rot_deg_per_m'][v] for v in algorithm_names],
                           config_labels, config_colors, legend=True)
        fig.tight_layout()
        fig.savefig(output_dir+'/'+dataset_nm +
                    '_trans_rot_error'+FORMAT, bbox_inches="tight", dpi=args.dpi)
        plt.close(fig)

and the code block I modified like this:

from matplotlib.patches import Patch          #it is necessary to add this line

def plot_odometry_error_per_dataset(dataset_rel_err, dataset_names, algorithm_names,
                                    datasets_outdir, plot_settings):
    for dataset_idx, dataset_nm in enumerate(dataset_names):
        output_dir = datasets_outdir[dataset_nm]
        print("Plotting {0}...".format(dataset_nm))
        rel_err = dataset_rel_err[dataset_idx]
        assert sorted(algorithm_names) == sorted(list(rel_err['trans_err'].keys()))
        distances = rel_err['subtraj_len']

        config_labels = []
        config_colors = []
        for v in algorithm_names:
            config_labels.append(plot_settings['algo_labels'][v])
            config_colors.append(plot_settings['algo_colors'][v])

        legend_elements = [Patch(facecolor=color, label=label)
                           for label, color in zip(config_labels, config_colors)]
        fig = plt.figure(figsize=(12, 3))
        ax = fig.add_subplot(
            121, xlabel='Distance traveled (m)',
            ylabel='Translation error (\%)')
        pu.boxplot_compare(ax, distances, [rel_err['trans_err_perc'][v] for v in algorithm_names],
                           config_labels, config_colors, legend=False)
        ax.legend(handles=legend_elements, loc='upper right')
        ax = fig.add_subplot(
            122, xlabel='Distance traveled (m)', ylabel='Rotation error (deg / m)')
        pu.boxplot_compare(ax, distances, [rel_err['rot_deg_per_m'][v] for v in algorithm_names],
                           config_labels, config_colors, legend=False)
        ax.legend(handles=legend_elements, loc='upper right')
        fig.tight_layout()
        fig.savefig(output_dir+'/'+dataset_nm +
                    '_trans_rot_error'+FORMAT, bbox_inches="tight", dpi=args.dpi)
        plt.close(fig)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants