File Exchange

image thumbnail

Poincare Sphere Plot of Polarimetry Stokes Vectors

version (255 KB) by Jeffrey Roth
This routine plots the Stokes vectors on a 3-D Poincare sphere using a graphical user interface.


Updated 04 May 2006

View License

This script plots the polarization Stokes vectors (S1, S2, S3) on a Poincare sphere. See "Polarized Light" by Collett (publ. Dekker) for a background on the optics.

Type "poincare" at the Matlab prompt and a graphical window should pop up. Enter an input data file in the GUI, then lick "Plot". You can also save the output graph to a .jpg file.

The input data file format can be modified to your instrument's output. Currently the format is compatible with the ThorLabs PA-430 Polarimeter. This data file format conforms to that produced by the above polarimeter's data logger application, which is part of the "polar4.exe" software provided for this instrument. This software is running on a Win95 machine with a Keithley DAS-1700 PCI board controlling the polarimeter.

This plot routine uses shading to indicate where on the 3-D surface the
data lies. That is, if the data lies on the back-side of the sphere, then it should be shaded; otherwise it is not shaded. The routine behaves in this manner in the figure window on the screen, however, unfortunately there is a bug regarding this shading algorithm if the figure is printed (directly to a printer) or if the figure is saved to a graphical file. Matlab suggested that this is due to a bug in the OpenGL graphics renderer. They have confirmed this bug in both Matlab 7.1 and Matlab
7.2. So far I have not found a suitable workaround. See the .m code for some comments from Matlab on the problem. If you discover a fix, I would be glad to hear it!

Cite As

Jeffrey Roth (2020). Poincare Sphere Plot of Polarimetry Stokes Vectors (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (8)

Minglei Ma

Boris Araujo

Dear Jeffrey (and community), I have already the script written in the tab, and I click on "Run" button, but it doesn't run.
my matlab program is 2017. What am I doing wrong? or What is not being done to try it and run this code your shared? Thank you.

Yongtai Chen

great code,thanks for sharing

xiaoxi chen

Sahriar Abdullah

The format of ThorLabs PA-430 Polarimeter data is <Time stamp>,<Stokes 0 - 3>,<DOP>,<DOLP>,<DOCP>,<Ellipticity>,<Orientation>\n
You can change other polarimeter data to this format and visulize the poincarre sphere

Shawn Hurley

Use print screen to capture any image you plot then paste into your favorite image editor such as paint to save into .jpg for instance.


Alberto Carrasco

Muy útil

MATLAB Release Compatibility
Created with R14SP3
Compatible with any release
Platform Compatibility
Windows macOS Linux