MATLAB: OpenGL setup for successful graphic rendering

MATLABopenglrendering

I am working on an application where MATLAB scripts (executed by MATLAB R2020b) are being called from a python application on a Centos 7 cloud-based VM. I am having difficulty getting the rendering from plot and imshow commands to work reliably. More information follows:
1) If have run the command "export MESA_GL_VERSION_OVERRIDE=2.1" in a bash terminal prior to running MATLAB, MATLAB will launch and render plots/images as expected
2) Setting OpenGL to 2.1 causes a conflict elsewhere in the application which needs a newer implementation which has forced me to set OpenGL to 3.3 by running the following command: "export MESA_GL_VERSION_OVERRIDE=3.3". This has caused rendering to fail in MATLAB
2.1) If you try running a simple plot command you get the following message:
>> plot(x,y)
Warning: MATLAB has disabled some advanced graphics rendering features by switching to software OpenGL. For more
information, click here.
MATLAB has experienced a low-level graphics error, and may not have drawn correctly.
Read about what you can do to prevent this issue at Resolving Low-Level Graphics Issues then restart MATLAB.
To share details of this issue with MathWorks technical support,
please include this file with your service request.
2.2) If you try to get open gl info you get the following:
>> opengl info
MATLAB has experienced a low-level graphics error, and may not have drawn correctly.
Read about what you can do to prevent this issue at Resolving Low-Level Graphics Issues then restart MATLAB.
To share details of this issue with MathWorks technical support,
please include this file with your service request.
Version: ''
Vendor: ''
Renderer: 'None'
RendererDriverVersion: ''
RendererDriverReleaseDate: ''
MaxTextureSize: 0
Visual: ''
Software: 1
HardwareSupportLevel: 'none (known graphics driver issues)'
SupportsGraphicsSmoothing: 0
SupportsDepthPeelTransparency: 0
SupportsAlignVertexCenters: 0
Extensions: {}
MaxFrameBufferSize: 0
2.3) Setting up the javaopts file as described in this thread does yield information about opengl, however the matlab still crashes if it tries to plot anything https://www.mathworks.com/matlabcentral/answers/251789-matlab-2015b-on-ubuntu-14-04-error-resolving-low-level-graphics-issues
>> opengl info
Version: '3.3 (Core Profile) Mesa 17.1.3'
Vendor: 'Brian Paul'
Renderer: 'Mesa X11'
MaxTextureSize: 16384
Visual: 'Visual 0x47, (RGBA 32 bits (8 8 8 8), Z depth 16 bits, Hardware acceleration, Double buffer, Antialias 0 samples)'
Software: 'true'
HardwareSupportLevel: 'none (known graphics driver issues)'
SupportsGraphicsSmoothing: 0
SupportsDepthPeelTransparency: 1
SupportsAlignVertexCenters: 0
Extensions: {76×1 cell}
MaxFrameBufferSize: 16384
Why is MATLAB crashing when "export MESA_GL_VERSION_OVERRIDE=3.3" has been executed? What can I do to resolve this issue?

Best Answer

Here is the solution that worked for me that was provided by Mathworks support:
Have you tried using a different renderer? Refer to the following link for more details and also share the renderer info with us: https://www.mathworks.com/help/matlab/creating_plots/resolving-low-level-graphics-issues.html
a) To configure a different renderer, execute the following MATLAB command:
>> set(groot,'DefaultFigureRenderer','painters')
b) In case you would like to revert the setting back to the default, execute the following command:
>> set(groot,'DefaultFigureRenderer','default')
Note that this doesn't truly resolve the openGL issue, but switches to a different, lower performance renderer. For my application this is acceptable.