Comments (4)
Hello @Jankowski-J - try matplotlib.pyplot.savefig
method (documentation), it's a standard built-in method in matplotlib
to save a figure
class object. Example: stackoverflow question
Package is a purpose-based wrapper above matplotlib
, so all logic and methods are inherited for respective objects.
from july.
I've tried what you have suggested, I've also looked into the properties available in object returned by july.heatmap()
method. I can't seem to find any relevant method to save the image.
The heatmap variable is of type AxesSubplot
and I don't know how to save that to file.
Below is a snippet of my code:
import numpy as np
from plotly_calplot import calplot
import matplotlib.pyplot as plt
import july
from july.utils import date_range
def main():
dates = date_range("2020-01-01", "2020-12-31")
data = np.random.randint(0, 14, len(dates))
heatmap = july.heatmap(dates, data, title='Github Activity', cmap="github")
# both of these lines throw an exception
heatmap.save_fig("saved_hm.png")
plt.save_fig("test_heatmap.png")
if __name__ == "__main__":
main()
from july.
@Jankowski-J - try plt.savefig("test_heatmap.png")
instead of plt.save_fig("test_heatmap.png")
, you have a typo underscore (..._...
) in a name of a method (see documentation). This method will take the current figure (~the last active figure) and save it
heatmap = july.heatmap(dates, data, title='Github Activity', cmap="github")
plt.savefig("test_heatmap.png")
Alternatively, try the next snippet because heatmap
object is <class 'matplotlib.axes._subplots.AxesSubplot'>
. Matplotlib allows to save figure
objects not axes
objects (see example stackoverflow question). It also allows to save the selected figure
fig, ax = plt.subplots(1, 1, figsize=(12, 10)) # create figure object and one axes objects
heatmap = july.heatmap(dates, data, title='Github Activity', cmap="github", ax=ax) # plot a chart to ax subplot
fig.tight_layout() # auto adjust the padding between and around subplots.
fig.savefig("saved_hm.png") # save figure
Also, check the dpi
and facecolor
params to increase the image quality and change the background color (from transparent to needed color code).
Also, there is already a pull request to save it inside the package interface - #27
from july.
Thank you for your explanation @Witold1 , now I can save the output.
I have no further questions, so I will close the issue soon.
from july.
Related Issues (8)
- calendar_plot() showing week number = 53 in the last week of January 2021 HOT 5
- Sliding calendar HOT 2
- Add colorbar argument to july.calendar_plot() HOT 2
- `value_label` - `add_value_label` - color of value_label HOT 1
- numpy.datetime64 not accepted as date HOT 1
- Allow customized title in calendar_plot HOT 1
- make modifications of matplotlib configuration on a local level HOT 1
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 july.