Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Legend color race condition #5242

Copy link
Copy link
Closed
Closed
Copy link
@jimrybarski

Description

@jimrybarski
Issue body actions

The colors of the symbols in my legend vary randomly each time I make a plot or save it to disk. It shifts between a set of three colors, one of which is completely correct, one of which has a single incorrect color, and one which is all wrong. Run the demo code below several times to see this. I have reproduced this on two separate machines, one of which is running the code in a Docker container.

I have noticed the Please do not ask for support with these customizations active. but since it lists nothing, I'm not sure what to make of that.

matplotlib version: 1.4.3
backend: Qt5Agg version 5.3.2

import matplotlib.pyplot as plt
import random

blue = [.365, .647, .855]
green = [.376, .741, .408]
purple = [.698, .463, .698]


def boxplot(data, title, x_label, y_label, legend_location="upper left"):
    fig = plt.figure(1, figsize=(9, 6))
    ax = fig.add_subplot(111)
    meanprops = dict(linestyle='-', linewidth=1.5, color=purple)
    boxprops = dict(linewidth=1.5, color=blue)
    whiskerprops = dict(linewidth=1.5, color=blue)
    capprops = dict(linewidth=1.5, color=blue)
    medianprops = dict(alpha=0.0)
    flierprops = dict(marker='+', color=green, markersize=12, mew=2)

    plt.plot([], c=purple, label='Mean', linewidth=1.5)
    plt.plot([], c=blue, label='1st Quartile', linewidth=1.5)
    plt.plot([], c=blue, label='3rd Quartile', linewidth=1.5, linestyle='--')
    plt.legend(loc=legend_location, numpoints=1)
    plt.plot([], c=green, label='Outlier', marker='+', markersize=12, mew=2, linestyle='')
    plt.legend(loc=legend_location, numpoints=1)

    values = [a for d in data.values() for a in d]
    max_value = max(values)
    bp = ax.boxplot([d for n, d in sorted(data.items())],
                    meanprops=meanprops,
                    capprops=capprops,
                    flierprops=flierprops,
                    medianprops=medianprops,
                    boxprops=boxprops,
                    whiskerprops=whiskerprops,
                    showmeans=True,
                    meanline=True,
                    labels=[i for i in range(49)])
    ax.set_ylim([0, max_value + 2])
    ax.set_axis_bgcolor('white')
    ax.set_xlabel(x_label)
    ax.set_ylabel(y_label)
    plt.suptitle(title)
    fig = plt.gcf()
    fig.set_size_inches(20, 10)
    plt.show()
    plt.close()

if __name__ == '__main__':
    data = {j: [random.randint(10, 100) for i in range(100)] for j in range(49)}
    boxplot(data, "Race Condition Plots", "X Axis", "Y Axis")
$ python3.4 /opt/bug.py --verbose-helpful 

non-network local connections being added to access control list
$HOME=/root
matplotlib data path /usr/local/lib/python3.4/dist-packages/matplotlib/mpl-data

*****************************************************************
You have the following UNSUPPORTED LaTeX preamble customizations:

Please do not ask for support with these customizations active.
*****************************************************************

loaded rc file /usr/local/lib/python3.4/dist-packages/matplotlib/mpl-data/matplotlibrc
matplotlib version 1.4.3
verbose.level helpful
interactive is False
platform is linux
CACHEDIR=/root/.cache/matplotlib
font search path ['/usr/local/lib/python3.4/dist-packages/matplotlib/mpl-data/fonts/ttf', '/usr/local/lib/python3.4/dist-packages/matplotlib/mpl-data/fonts/afm', '/usr/local/lib/python3.4/dist-packages/matplotlib/mpl-data/fonts/pdfcorefonts']
generated new fontManager
backend Qt5Agg version 5.3.2
1.4.3
Unrecognized line style none, <class 'str'>
Unrecognized line style none, <class 'str'>
Unrecognized line style none, <class 'str'>
Unrecognized line style none, <class 'str'>
Unrecognized line style none, <class 'str'>
Unrecognized line style none, <class 'str'>
Unrecognized line style none, <class 'str'>
Unrecognized line style none, <class 'str'>
Unrecognized line style none, <class 'str'>
Unrecognized line style none, <class 'str'>
Unrecognized line style none, <class 'str'>
Unrecognized line style none, <class 'str'>
Unrecognized line style none, <class 'str'>
Unrecognized line style none, <class 'str'>
Unrecognized line style none, <class 'str'>
Unrecognized line style none, <class 'str'>
Unrecognized line style none, <class 'str'>
Unrecognized line style none, <class 'str'>
Unrecognized line style none, <class 'str'>
Unrecognized line style none, <class 'str'>
Unrecognized line style none, <class 'str'>
Unrecognized line style none, <class 'str'>
Unrecognized line style none, <class 'str'>
Unrecognized line style none, <class 'str'>
Unrecognized line style none, <class 'str'>
Unrecognized line style none, <class 'str'>
Unrecognized line style none, <class 'str'>
Unrecognized line style none, <class 'str'>
Unrecognized line style none, <class 'str'>
Unrecognized line style none, <class 'str'>
Unrecognized line style none, <class 'str'>
Unrecognized line style none, <class 'str'>
Unrecognized line style none, <class 'str'>
Unrecognized line style none, <class 'str'>
Unrecognized line style none, <class 'str'>
Unrecognized line style none, <class 'str'>
Unrecognized line style none, <class 'str'>
Unrecognized line style none, <class 'str'>
Unrecognized line style none, <class 'str'>
Unrecognized line style none, <class 'str'>
Unrecognized line style none, <class 'str'>
Unrecognized line style none, <class 'str'>
Unrecognized line style none, <class 'str'>
Unrecognized line style none, <class 'str'>
Unrecognized line style none, <class 'str'>
Unrecognized line style none, <class 'str'>
Unrecognized line style none, <class 'str'>
Unrecognized line style none, <class 'str'>
Unrecognized line style none, <class 'str'>
libGL error: failed to open drm device: No such file or directory
libGL error: failed to load driver: i965
libGL error: unable to load driver: swrast_dri.so
libGL error: failed to load driver: swrast
findfont: Matching :family=sans-serif:style=normal:variant=normal:weight=normal:stretch=normal:size=medium to Bitstream Vera Sans ('/usr/local/lib/python3.4/dist-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf') with score of 0.000000
findfont: Matching :family=sans-serif:style=normal:variant=normal:weight=normal:stretch=normal:size=large to Bitstream Vera Sans ('/usr/local/lib/python3.4/dist-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf') with score of 0.000000

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.