dougollerenshaw / figrid Goto Github PK
View Code? Open in Web Editor NEWUtilities for formatting matplotlib figures
License: MIT License
Utilities for formatting matplotlib figures
License: MIT License
Thanks for making this useful package! I have a problem, when I make a plot it doesn't fill the entire figure. I get a white border around it, especially on the left and top.
Code:
fig = plt.figure(figsize=(7, 9), dpi=DPI)
ax = {'panel_A': fg.place_axes_on_grid(fig, xspan=[0.1, 1], yspan=[0, 0.18]),
'panel_B': fg.place_axes_on_grid(fig, xspan=[0.1, 1], yspan=[0.25, 0.5],
dim=[1, n_columns + 1], wspace=0.3),
'panel_C': fg.place_axes_on_grid(fig, xspan=[0.1, 1], yspan=[0.55, 0.8],
dim=[1, n_columns + 1], wspace=0.3),
'panel_D': fg.place_axes_on_grid(fig, xspan=[0.2, 0.45], yspan=[0.85, 1]),
'panel_E': fg.place_axes_on_grid(fig, xspan=[0.55, 1], yspan=[0.85, 1])}
# Add subplot labels
labels = [{'label_text':'a', 'xpos':0, 'ypos':0, 'fontsize':10, 'weight': 'bold',
'ha': 'right', 'va': 'bottom'},
{'label_text':'b', 'xpos':0, 'ypos':0.2, 'fontsize':10, 'weight': 'bold',
'ha': 'right', 'va': 'bottom'},
{'label_text':'c', 'xpos':0, 'ypos':0.55, 'fontsize':10, 'weight': 'bold',
'ha': 'right', 'va': 'bottom'},
{'label_text':'d', 'xpos':0, 'ypos':0.85, 'fontsize':10, 'weight': 'bold',
'ha': 'right', 'va': 'bottom'},
{'label_text':'e', 'xpos':0.5, 'ypos':0.85, 'fontsize':10, 'weight': 'bold',
'ha': 'right', 'va': 'bottom'}]
fg.add_labels(fig, labels)
As you can see here (hopefully) the figure doesn't start at the top left:
When running this block of code:
import figrid as fg
import matplotlib.pyplot as plt
fig = plt.figure(figsize=(15,7))
axes = {
'axis_array': fg.place_axes_on_grid(fig, xspan=[0, 1], dim=[3, 1], sharex=True)
}
I get:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Input In [X], in <cell line: 6>()
2 import matplotlib.pyplot as plt
4 fig = plt.figure(figsize=(15,7))
5 axes = {
----> 6 'axis_array': fg.place_axes_on_grid(fig, xspan=[0, 1], dim=[3, 1], sharex=True)
7 }
File ~/.conda/envs/XX/lib/python3.9/site-packages/figrid/__init__.py:67, in place_axes_on_grid(fig, dim, xspan, yspan, wspace, hspace, sharex, sharey, frameon)
65 inner_ax[row][col].xaxis.set_ticks_position('bottom')
66 elif row < dim[0] and sharex == True:
---> 67 plt.setp(inner_ax[row][col].get_xtick)
69 if col == 0 and sharey == True:
70 inner_ax[row][col].yaxis.set_ticks_position('left')
AttributeError: 'AxesSubplot' object has no attribute 'get_xtick'
It looks like I need to deal with the case in which the inner_ax has only 1 col.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.