Using MiePlot to Simulate a Rainbow


Last updated: April 3, 2026

MiePlot is a graphing and simulation program for rainbows, glories, and coronae developed by Philip Laven; you can download it for free from his site!

Figuring out how to simulate a rainbow was a little tricky for me at first, so I have documented my findings here. You're presented with a graph for a single wavelength, showing how intense its light is at different angles away from the sun (0 deg is the center of the sun and 180 deg is the antisolar point).

How to meet the Simulation Conditions

You can't simulate anything at first, because you can't simulate with only a single wavelength.

Screenshot of the light settings field with the number of wavelengths dropdown open, with 30 highlighted.

Under the light group we can change how many wavelengths are simulated, which will be distributed across 380-700 nm. I chose 30, but 10 will also work. Just keep in mind the the more wavelengths you select, the more calulations the program will have to do, which may take longer to load.

The calculation model drop down with the default value of Mie at the top, and Airy highlighted.

Speaking of calculations, I am going to change the mathematical model for these simulations. By default it uses Mie theory, hence the name MiePlot, but I am going to change it to Airy theory which is less intensive. This is to the right of the light field.

The new plot button, which is directly under the top bar, under the file and view tabs.

Before simulating, we have to redo the plot with our updated information. It will give two pop ups about the complex values of the reflective index, you can just hit OK on these. The simulate button will now apear, but before you rejoice, you will have to click the New plot button again. Your chart should look like this now:

Graph of mostly black until 125 degrees, where a broad white bands forms. After 150 degrees a slightly smaller band forms with white in the middle and bluish on the 150 degree side and redish on the 155 degree side. A thinner dull pastel rainbow band is next, and they resolve into faint grey bands. towards 180 degrees.

Notice the bars at the top, with the banding on the right, this is what we want to see.

The settings under the math model dropdown. The simulation button is now visible.

We can finally hit Simulation now! It's in the same secion as the calculations drop down.

Simulation Photo Notes

The simulation screen with everything left as default.

You'll get this screen, which already has a picture preloaded. The intention of the simulation mode is to actually lay your simulation over a photo as a way to evaulate your image of a rainbow, glory, or corona. By changing the parameters to better match your photo, you can learn more about the conditions that resulted in the phenomenon, such as what drop size produced it.

But I'm not looking to use it for that, as cool as that may be. I mention it because instead of giving you zoom options, MiePlot gives you focal length based on which kind of camera you used for your photo. I'm not using a real photo, so I use this as my zoom, small values for zooming out, and high values for zooming in.

The documentation notes that the uploaded image should be in 3:2 or 4:3 ratio, so I made a flat color image 700px wide by 525px tall. You may be able to use a larger image if your screen is larger than mine. It has to be in jpg format.

There is also a field for background color. I change the RGB values to match that of my image. You don't actually need an image if your simulation covers the entire default photo, but its nice for when your simulation is smaller than the photo, or you want a larger canvass than the default image.

If you select Show simulation a soft glory will slowly plot over the image. The next section will cover how to do a rainbow rather than a glory.

Simulating a Rainbow

Let's go back to the graph window, but don't close the simulation window. The next important thing we are going to change is the drop size.

The particle size field with the radius changed to 200. Monodisperse is left selected as default.

The default drop size has a 10μm radius, making it 20μm wide. Thats fine for a glory or corona, but rainbows have larger drops, so you'll want a radius from about 200μm to 1000μm (0.4-2mm in diameter). I chose a 200μm radius.

The light source field, which has only two options, point and sun.

You will also want to change the light source from a point, to the sun. If you click New plot again, you'll get this:

Chart showing black empty space until about 138 degrees on the x axis, where it then shows a thin sliver of a rainbow with thinner supernumerary bands which resolve into grey from around 145 degrees to 180 degrees.

If you simulate it and select Show simulation, you will get plain grey, but its okay, you didn't do anything wrong, you're just "zoomed" too far in.

Change the focal length to 14. Also be sure that your center is the Anti-solar point, click it again even if it already says anti-solar point. This centers the rainbow or glory since the preview image is offcenter, and just clicking the picture can change the center (by design, for evaluating photos).

Simulation of a primary rainbow on a black background, featuring many clearly defined supernumerary bands inside. Aside from already described conditions, the rest are default. The mapping function is rectilinear, the background color RBG values are each 0, the light source and vieing conditions are unpolarized, all four quadrants are selected, the x value is 288, and the y value is 216.

Now we get to see a rainbow! One made by small 400μm wide drops, giving it nice supernumerary bands. They are very defined, as all the drops are exactly the same size, this tutorial will cover simulating rainbows with drop size variation.

Go ahead and play around! Change the drop size, your background image, etc!

Graph notes

You can change the limits of the x axis for the graph, which can allow you to crop out excess empty space. By default it is 0-180 degrees away from the sun, but since we are simulating rainbows, we can crop it to 130-180 degrees (180 - 42 = 138)

Screenshot of the angle scale field, with a minimum angle of 130 and a max angle of 180. Angular resolution is left as 0.1.

This will change our graph like so:

The graph with a sliver of rainbow starting around 138 degrees, including supernumeray bands, ang then greyness out to 180 degrees.

Both the line and the preview bars are streched out to take up more of the field. You may notice that there is color banding in the bars. This won't affect the appearance of the simulation, but if you are interested in these bars themselves you can smooth them out without additional calculations.

Screenshot of the Advanced tab in the top bar open, with cubic interpolation highlighted.

Under the Advanced tab, you can select Cubic interpolation, which will automatically smooth out the bands.

The smoothed out rainbow bands above the graph.

Simulating single color rainbows

If you can't simulate with only one wavelength, how do we simulate what a certain color component of the rainbow (or glory/corona) would look like?

It turns out you can edit the range of wavelengths!

The Advanced tab in the top bar open.

Go to the Advanced tab again, then to Spectrum, and then 380 - 700 nm band. This will bring up a small window where you can change this range from the sun's visible spectrum, to whatever you prefer (as long as it is within this range).

Screenshot of the spectrum limits.

I changed this range to 410 - 420 nm, which should be violet. You could even do something like 410-411 if you want to be more precise. You'll have to click New plot again to recalculate. We can keep our number of wavelengths as 30, MiePlot will just use values between whole numbers.

The violet graph. A simulated rainbow that is just purple on a black background, with many clear purple supernumerary bands.

We can simulate this to get a violet rainbow with supernumeraries. The default image shows through because we cropped the angle to 130-180. The circle border is the 130 limit. We can either extend our limit back and resimulate, or change our image to a flat black one to match the simulation background.

Drop size variation

We are going to switch our math model back to Mie for this one, and since mie calculations are more intensive, we are going reduce our number of wavelengths to 10. I'm keeping the radius as 200μm.

The settings for the light field, calculation type, and brightness. The refractive index is left as 1, and polariation is left as both. The drop down under Mie is left as 'intensity vs scattering angle'.

As shown in the screenshot, we are also going to reduce our brightness to 0.3; this is not necessary, but will look more realistic.

The angle scale field under the light source field. The max angle is left at 180, and the angular resolution is left at 0.1.

We are also going to start our angle range at 120 (minimum angle), to reduce to calculation load, but to also include the secondary. Go ahead and see what it looks like without drop variation (New plot > Simulation > Show simulation). You may have to reset the center and change the focal length to 14 again.

You should see a primary rainbow with clearly defined supernumerary bands and a secondary rainbow showing in the corners.

Now lets add the drop variation.

The particle size field which includes settings for disperse sized drops. The first drop down under the disperse button contains the word 'normal', the other settings are described.

Select Disperse and that will bring up a few settings below it. I chose 10% for the standard deviation (how much the drops will vary in size) and 5 for N, which will produce 5 different drop sizes for each wavelength, increasing our calculations from just 10, to 50. This will take a little while to load, which is why we chose so few wavelengths and the smallest N value.

After the calculations are complete, do a new plot and simulate it, the bands will be softer and less distinct, more realistic.

Simulation of a full circle rainbow produced by 200μm drops on a sky blue background. The top half has sharp supernumerary bands and is labelled as 'no SD'. The bottom half has blurred supernumeray bands, only showing one distinct one inside the primary bow. It is labelled as '10% SD, N = 5'. The bottom left corner details parameters already described.

Here in the simulation settings I changed the background color and plotted the disperse rainbow over the monodisperse rainbow by deselecting the two top quadrants before clicking Show simulation. I added the line and annotations afterwards.

Snippet of the simulation settings, showing the simulation background RBG values changed to 120, 140, 180 respectively. Only the south west and south east quadrants are selected.

Thats the end of my insight, have fun making simulations!


Go home? Home