Skip to content

Commit

Permalink
Add logo and bump version to 0.2.0. Close #2.
Browse files Browse the repository at this point in the history
  • Loading branch information
juseg committed Feb 3, 2020
1 parent 5063a61 commit 135ecfc
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
44 changes: 44 additions & 0 deletions examples/logo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env python
# Copyright (c) 2020, Julien Seguinot <[email protected]>
# GNU General Public License v3.0+ (https://www.gnu.org/licenses/gpl-3.0.txt)

"""Plot Absplots logo explaining what it's for."""

import absplots as apl

# init figure with high aspect ratio
fig, grid = apl.subplots_mm(figsize=(120, 40), ncols=2, gridspec_kw=dict(
left=10, right=10, wspace=10, bottom=10, top=10, width_ratios=(3, 4)))

# add logo text
kwargs = dict(fontsize='52', fontweight='bold', ha='center', va='center')
grid[0].text(0, 0, 'Abs', color='C0', **kwargs)
grid[1].text(0, 0, 'plots', color='0.25', **kwargs)

# plot some data
for i, ax in enumerate(grid):
ax.set_xlim(-1.1, 1.1)
ax.set_ylim(-1.1, 1.1)
ax.tick_params(color='0.5', labelbottom=False, labelleft=False)
for spine in ax.spines.values():
spine.set_color('0.5')

# add double arrows in the margins
kwargs = dict(xycoords='axes fraction', textcoords='offset points',
arrowprops=dict(arrowstyle='<->', color='0.5'))
cm2pts = 72/2.54
grid[0].annotate('', (0, 0.3), (-cm2pts, 0), **kwargs)
grid[0].annotate('', (1, 0.3), (+cm2pts, 0), **kwargs)
grid[1].annotate('', (1, 0.3), (+cm2pts, 0), **kwargs)
grid[0].annotate('', (0.45, 1), (0, +cm2pts), **kwargs)
grid[1].annotate('', (0.06, 0), (0, -cm2pts), **kwargs)

# add text labels in the margins
fig.text(0.24, 0.88, '10 mm', color='0.5', ha='left', va='center')
fig.text(0.53, 0.12, '10 mm', color='0.5', ha='left', va='center')
fig.text(0.042, 0.53, '10\nmm', color='0.5', ha='center', va='center')
fig.text(0.447, 0.53, '10\nmm', color='0.5', ha='center', va='center')
fig.text(0.958, 0.53, '10\nmm', color='0.5', ha='center', va='center')

# save
fig.savefig('logo.png', dpi=254)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

setuptools.setup(
name='absplots',
version='0.1.0',
version='0.2.0',
author='Julien Seguinot',
author_email='[email protected]',
description='Matplotlib subplots with absolute margins in mm or inches',
Expand Down

0 comments on commit 135ecfc

Please sign in to comment.