Comments (7)
Right now you could do this (all code without testing it ...):
from ggplot import * # sets the rcParam for figsize to a default
import matplotlib as mpl
mpl.rcParams["figure.figsize"] = "11, 8" # or whatever you want
print( ggplot(...) +...)
Be aware that every usage of theme_gray()
or theme_bw()
will overwrite the mpl.rcparams again, so if you want to use these themes explicitly, you need to do it like this:
from ggplot import *
theme_bw() # sets the default to the bw settings
import matplotlib as mpl
mpl.rcParams["figure.figsize"] = "11, 8"
print( ggplot(...) +...) # don't use any theme here!
Note that this hack is changed in the "Theme as contextmanager" PR #75, so if that's merged you could do this:
from ggplot import *
mpl.rcParams["figure.figsize"] = "11, 8"
print( ggplot(...) + theme_matplotlib(rc={"figure.figsize": "11, 8"}, matplotlib_defaults=False)
There is also a ggsave()
, but right now this doesn't take a size parameter (I opened #96 for this)
from ggpy.
I tryed the first code example and it works. Thanks
from ggpy.
ggsave
should now handle this
from ggpy.
in 0.5.8, theme is lost when you change size... is there a way to keep both theme and size?
Here's example code:
import pandas as pd
import numpy as np
import matplotlib as mpl
%matplotlib inline
from ggplot import *
theme_bw()
mpl.rcParams['figure.figsize'] = "15.0, 10.0"
gsize = theme_matplotlib(rc={"figure.figsize": "15, 10"}, matplotlib_defaults=False)
df = pd.DataFrame(np.random.randn(100,2),columns=['x','y'])
ggplot(df,aes('x','y')) + geom_line() + gsize
from ggpy.
When I print to a file , the size does not change. It remains same as original. Any way to control it?
from ggpy.
I was able to control the size of the figure by setting theme(plot_margin=...)
:
ggplot(df,aes('x','y')) + geom_line() + theme(plot_margin = dict(right = 15, top=10))
How about implementing an alternative plot_margin
as tuple of two (width, height)
?
from ggpy.
Another solution, if you don't want to alter matplotlib's configuration:
from ggplot import *
from matplotlib import pyplot as plt
p = (ggplot(diamonds,
aes(x='x', y='y', color='cut', fill='cut')) +
geom_point() +
facet_wrap(x='cut'))
# This command "renders" the figure and creates the attribute `fig` on the p object
p.make()
# Then you can alter its properties
p.fig.set_size_inches(15, 5, forward=True)
p.fig.set_dpi(100)
p.fig
# And display the final figure
plt.show()
from ggpy.
Related Issues (20)
- [Feature Request]: Plot directly onto a matplotlib axis HOT 1
- the numbers squeeze on the x-axis or y-axis
- Wrong code
- Is this project dead? HOT 16
- "metaclass conflict" error when using ggplot 0.6.8 with six 1.10.0+
- Import does not work with pandas 0.23.4
- unable to import in jupyter notebook HOT 5
- Warning received when using color aesthetic with geom_point
- Import issue in jupyter notebook
- AttributeError: module 'pandas' has no attribute 'tslib' HOT 35
- Can't facet on variable with more than 9 levels
- facet_grid fail with a category type
- facet_grid repeat x-axis
- pandas sort issue
- How about make it available with dfply?
- Link to an actively developed project called "plotnine" which provides ggplot functionality in python.
- ggplot installs for python3.9.1.0, but import ggplot gets error re pandas attribute tslib HOT 2
- plot multiple geoms on top of each other
- Looking for `ggplot` substitution HOT 2
- Questions about Copilot + Open Source Software Hierarchy
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ggpy.