Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7761845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:14:27+00:00 2026-06-01T14:14:27+00:00

I usually use ax.set_rasterized(True) to rasterize the figure so that it could handle transparency

  • 0

I usually use ax.set_rasterized(True) to rasterize the figure so that it could handle transparency when saved as in eps format, but the rasterization also blurs the axis labels and ticklabels, so is there a way to rasterize only patches within the axis rather than the whole figure? or is there a better around for exporting eps format with transparency? Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T14:14:29+00:00Added an answer on June 1, 2026 at 2:14 pm

    As matplotlib Artists can be rasterized, any class derived from Artist (http://matplotlib.sourceforge.net/api/artist_api.html) can be rasterized with the keyword rasterized set to True. So you can only rasterize your patches.

    I just tried some combinations and it seems to work. However the quality seems to be not very good (see also http://www.mail-archive.com/matplotlib-users@lists.sourceforge.net/msg13276.html).

    import numpy as np
    import matplotlib.pyplot as plt 
    
    
    def add_patch(ax, **kwargs):
        if 'rasterized' in kwargs and kwargs['rasterized']:
            ax.set_rasterization_zorder(0)
        ax.fill_between(np.arange(1, 10), 1, 2, zorder=-1, **kwargs)
        ax.set_xlim(0, 10) 
        ax.set_ylim(0, 3)
        if 'alpha' in kwargs and kwargs['alpha'] < 1:
            txt = 'This patch is transparent!'
        else:
            txt = 'This patch is not transparent!'
        ax.text(5, 1.5, txt, ha='center', va='center', fontsize=25, zorder=-2,
                rasterized=True)
    
    fig, axes = plt.subplots(nrows=4, sharex=True)
    add_patch(axes[0], alpha=0.2, rasterized=False)
    add_patch(axes[1], alpha=0.2, rasterized=True)
    add_patch(axes[2], rasterized=False)
    add_patch(axes[3], rasterized=True)
    
    plt.tight_layout()
    plt.savefig('rasterized_transparency.eps')
    

    I converted the eps to png to show it in the browser:

    rasterized_transparency.png

    See also: How to save figures to pdf as raster images in matplotlib.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I usually use Visual Studio Team System 2008 Source Control Explorer with TFS, but
I haven't play enough with this and usually use mocks, but I wonder what
I usually use the Ruby on Rails framework but for this project I need
Usually i use SQL Server as database for my project, but one of my
i usually use ShareKit to add share featuring into my apps, but since with
I usually use the following pipeline to grep for a particular search string and
I usually use this line to import file from out of the current folder
I usually use pointers in the following manner char *ptr = malloc( sizeof(char) *
I usually use a TabControl and somehow hide the tabs and navigate through them.
I usually use ORM instead of SQL and I am slightly out of touch

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.