Skip to content

is it possible to control edge color? #37

Description

@JosephBARBIERDARNAL

Hello!

Is there a way to control the border of each block? Because if there isn't, I get the impression that it's not possible to create dark, satisfying graphics with pywaffle.

Here is an example (and its output):

import matplotlib.pyplot as plt
import pandas as pd
from pywaffle import Waffle

path = 'https://raw.githubusercontent.com/holtzy/R-graph-gallery/master/DATA/share-cereals.csv'
df = pd.read_csv(path)

def remove_html_tag(s):
    return s.split('</b>')[0][3:]

df['lab'] = df['lab'].apply(remove_html_tag)
df = df[df['type'] == 'feed']

background_color = "#222725"
pink = "#f72585"
black = "#4F0325"

number_of_bars = len(df)  # one bar per continent

# Init the whole figure and axes
fig, axs = plt.subplots(
   nrows=number_of_bars,
   ncols=1,
   figsize=(8, 6)
)
fig.set_facecolor(background_color)
ax.set_facecolor(background_color)


# Iterate over each bar and create it
for (i, row), ax in zip(df.iterrows(), axs):

    share = row['percent']
    values = [share, 100-share]

    Waffle.make_waffle(
        ax=ax,
        rows=4,
        columns=25,
        values=values,
        colors=[pink, black],
        edgecolor='white'
    )

plt.show()
Screenshot 2024-07-16 at 14 25 50

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions