Skip to content

Commit

Permalink
update README
Browse files Browse the repository at this point in the history
  • Loading branch information
gyli committed Nov 17, 2017
1 parent bee4a9f commit 1e9efda
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 18 deletions.
9 changes: 5 additions & 4 deletions README.rst
Expand Up @@ -22,21 +22,22 @@ Installation
Examples
--------

Basic example:
1. Basic example:

.. code:: python
import matplotlib.pyplot as plt
from pywaffle import Waffle
fig = plt.figure(FigureClass=Waffle, rows=6, columns=10, values=[30, 20, 10])
# Define a 10 * 3 block matrix, 1 block = 2 unit of values
fig = plt.figure(FigureClass=Waffle, rows=3, columns=10, values=[30, 20, 10])
plt.show()
.. raw:: html

<img src="README_images/basic.png", width="400px">

Use dictionary; Use absolute value as block number, without defining columns:
2. Use values in dictionary; use absolute value as block number, without defining columns:

.. code:: python
Expand All @@ -47,7 +48,7 @@ Use dictionary; Use absolute value as block number, without defining columns:

<img src="README_images/absolute_block_numbers.png", width="400px">

Add title, legend and background color:
3. Add title, legend and background color; customized block color:

.. code:: python
Expand Down
Binary file modified README_images/absolute_block_numbers.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_images/basic.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 10 additions & 8 deletions README_images/generate_plots.py
@@ -1,7 +1,7 @@
#!/usr/bin/python
# -*-coding: utf-8 -*-

# python3 -m README_images.generate_plots
# Run `python3 -m README_images.generate_plots` on root folder to generate plots for README

import matplotlib.pyplot as plt
from pywaffle.waffle import Waffle
Expand All @@ -10,20 +10,22 @@
image_folder = 'README_images/'

# Basic
fig = plt.figure(FigureClass=Waffle, rows=6, columns=10, values=[30, 20, 10])
fig = plt.figure(FigureClass=Waffle, rows=3, columns=10, values=[30, 20, 10])
fig.savefig(image_folder + 'basic.png', bbox_inches='tight', dpi=200)


# Absolute block number and value in dict
# Use values in dictionary; use absolute value as block number, without defining columns
fig = plt.figure(FigureClass=Waffle, rows=6, values={'Cat1': 35, 'Cat2': 24, 'Cat3': 9},
legend_args={'loc': (0, -0.15)})
fig.savefig(image_folder + 'absolute_block_numbers.png', bbox_inches='tight', dpi=200)

# Add title, legend and background color

# Add title, legend and background color; and change block color
fig = plt.figure(FigureClass=Waffle, rows=6, values={'Cat1': 35, 'Cat2': 24, 'Cat3': 9},
colors=("#FCF8C1", "#CEEEF9", "#E9DBF9"),
title_args={'label': 'Here is the title', 'loc': 'left'},
legend_args={'loc': (0, -0.15), 'facecolor': '#EAEAEA'})
fig.gca().set_facecolor('#EAEAEA')
fig.set_facecolor('#EAEAEA')
fig.savefig(image_folder + 'title_and_legend.png', bbox_inches='tight', dpi=200, facecolor='#EAEAEA')
legend_args={'loc': (0, -0.15), 'facecolor': '#EEEEEE'})
fig.gca().set_facecolor('#EEEEEE')
fig.set_facecolor('#EEEEEE')
fig.savefig(image_folder + 'title_and_legend.png', bbox_inches='tight', dpi=200, facecolor='#EEEEEE')

Binary file modified README_images/title_and_legend.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion pywaffle/waffle.py
Expand Up @@ -6,7 +6,7 @@
from matplotlib.patches import Rectangle, Patch
import matplotlib.font_manager as fm

prop = fm.FontProperties(fname='font/FontAwesome.otf')
# prop = fm.FontProperties(fname='font/FontAwesome.otf')


def ceil(a, b):
Expand Down
14 changes: 9 additions & 5 deletions tests/test.py
Expand Up @@ -3,10 +3,14 @@

import matplotlib.pyplot as plt
from pywaffle.waffle import Waffle
import unittest


fig = plt.figure(FigureClass=Waffle, height=10, values=[10, 20, 30], interval_ratio_x=0.2, interval_ratio_y=0.2,
colors=("#969696", "#1879bf", "#009bda"),
labels=("cat1", "cat2", "cat3"),
title_args={'label': 'Test Figure', 'loc': 'left', 'fontdict': {'fontsize': 10}})
plt.show()
class TestWaffle(unittest.TestCase):
def test_legend(self):
fig = plt.figure(FigureClass=Waffle, rows=10, values=[10], labels=["cat1"])
self.assertEqual(fig.gca().get_legend().texts[0]._text, 'cat1')


if __name__ == '__main__':
unittest.main()

0 comments on commit 1e9efda

Please sign in to comment.