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 7538231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:04:17+00:00 2026-05-30T07:04:17+00:00

When running MATLAB in a batch mode without a display (e.g. with the $DISPLAY

  • 0

When running MATLAB in a batch mode without a display (e.g. with the $DISPLAY UNIX environment variable unset, or with the matlab -nodisplay flag at startup), normally you cannot use the opengl renderer. Instead you must settle for the painters renderer. For example:

>> print -dpng -opengl fig.png
Warning: OpenGL mode can not be used in terminal emulation mode; ignoring option. 

Unfortunately, painters often gives poor results when working with 3D scenes with patches, lighting, transparency, etc.. Here is one simple example (using a display for now) where the alpha is lost:

peaks
alpha(0.5)
print -dpng -opengl peaks_opengl.png
print -dpng -painters peaks_painters.png

enter image description here


Because of these limitations, I was very excited to find the mostly-undocumented hardcopy() built-in MATLAB function, which does somehow let you use the opengl renderer without a display. This function underlies the terrific export_fig() function. Now I am able to very rapidly save high quality 3D figures in batch mode.

However, there is one catch: All text is lost when the figure gets passed through the hardcopy() function. For example:

plot(1,1)
title('TEST')
>> A = hardcopy(gcf, '-Dopengl', '-r300');
Warning: Failed to draw text string
> In /Applications/MATLAB_R2010b.app/toolbox/matlab/graphics/hardcopy.p>hardcopy at 21

The output figure is completely lacking any text (no axis ticks labels and no title):

export_fig axis.png -opengl

enter image description here

So what I’m wondering is: How can I get the opengl renderer to work with text in batch mode? Is there a way I can get text to work with the hardcopy() function? Perhaps a way to rasterize the text beforehand? Or a way to combine a painters hardcopy of the text and an opengl hardcopy of the plot? Alternatively, is there a completely different route to make this work than the hardcopy() function? Also note that the problem is unlikely to be with my system setup, since it is reproducible under both Mac OS and Ubuntu.

  • 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-05-30T07:04:19+00:00Added an answer on May 30, 2026 at 7:04 am

    If you’re using Linux, you can use a software OpenGL renderer (modern versions of Matlab have one bundled).
    Such an option does not exist for Mac OS, at least not with current Matlab versions.
    Windows is easy – even the batch mode runs a display, so you can work as usual.

    1. Run Xvfb :1 &, which creates a (virtual) framebuffer X server.
    2. Prepare your code in some file, say bla.m :

      opengl software;
      peaks
      alpha(0.5);
      print -dpng -opengl peaks_opengl.png
      exit
      

      It’s very important not to forget opengl software, as you imagine.

    3. Run the following command:

      cat bla.m | matlab -display :1 -logfile log.txt
      

      which makes Matlab execute whatever’s in bla.m, on the virtual display, and writes whatever Matlab outputs into log.txt. You can drop the logfile when everything seems to be working. Also, note that :display :1 has to fit the number you provided in the Xvfb invocation.

    4. Profit.

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

Sidebar

Related Questions

What happens for a global variable when running in the parallel mode? I have
I'm new to MATLAB and mrVista. I'm running Matlab Version 7.8.0.347 (R2009a) 32-bit(win32) from
I'm running a long simulation in MATLAB that I've realized I need to stop
I have a Matlab program that is running longer than I'd like it to.
In MATLAB, why does the file have to be saved prior to running ?
I am running matlab on 48 virtual machines and would like to automate it.
i have two machines running MATLAB and i need to exchange information(numbers,images) between them,is
Hey all. Im trying to sort out how to get MATLAB running as best
I have a C# program which should call Matlab for running a m-file and
The x-axis and y-axis are interchanged in the figure by running the following matlab

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.