FREE shipping to on qualifying orders when you spend or more, processed by Ossila BV. All prices ex. VAT. Qualifying orders ship free worldwide! Fast, secure, and backed by the Ossila guarantee. It looks like you are visiting from , click to shop in or change country. Orders to the EU are processed by our EU subsidiary.

It looks like you are using an unsupported browser. You can still place orders by emailing us on info@ossila.com, but you may experience issues browsing our website. Please consider upgrading to a modern browser for better security and an improved browsing experience.

Plotting I-V Curves using Python

Plotting I-V Curves using Python

Ossila Solar Cell I-V software (compatible with the Ossila Solar Cell IV Test System) saves I-V data (or J-V data) in the following form.

 

This data can be easily plotted using data visualisation software such as Excel, Origin or SciDAVis. You can also use the following Python code to plot this data using Panda DataFrames. Just copy and paste the code below into your Python virtual environment and start plotting.

Testing a Solar Cell in the Ossila Solar Cell Testing Bundle

Solar Cell Testing Kit

  • Class AAA
  • Easy Solar Cell Characterisation
  • Unbeatable Value

Available From £3800

Python Code for I-V Curves


This section of code can be used to read an Ossila I-V Data .csv into a Panda DataFrame and prepare the data for plotting.

#%%
# Import the following packages
# These packages are included with Python
import csv
from pathlib import Path
from tkinter import filedialog

# These packages need to be installed using pip
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

# Read in .csv file as a DataFrame
file_path = filedialog.askopenfile()
data = pd.read_csv(file_path, skiprows=1, engine='python') 

#%%
# This cell will define the headers for your DataFrame

# Find the number of pixels on your device
number_of_pixels = int(data.shape[1] / 4)

# Create a list of column names: the Forward + Reverse sweep for each pixel
labels = []
for i in range(1, number_of_pixels + 1):
    labels.append(f'Pixel {i} Forward V')
    labels.append(f'Pixel {i} Forward J')
    labels.append(f'Pixel {i} Reverse V')
    labels.append(f'Pixel {i} Reverse J')

# relabel the column heads
data = data.set_axis(labels, axis='columns')

#%%
# Convert J from A/cm2 to mA/cm2
for i in range(1, number_of_pixels + 1):
    data[f'Pixel {i} Forward J'] = data[f'Pixel {i} Forward J'] * 1000
    data[f'Pixel {i} Reverse J'] = data[f'Pixel {i} Reverse J'] * 1000

#%%
# Define colours if needed in this cell
# One needed for each pixel if you are using
colours = ['#384A9C', '#418FDE', '#AC1E2C', '#54565A', '#CCD4EC', '#0C9748', '#ffc125', '#000000']

You can plot the I-V sweep of an individual pixel using the code below.

#%%
# This cell will plot the forwards and reverse sweep for a specific defined pixel

# Define the pixel you want to plot
which_pixel = input('Please enter the pixel you want to plot.\n')

# Plot the J-V curve 
# If not defining colours, remove "colour=colours[0]"
plt.plot(
    data[f'Pixel {which_pixel} Forward V'],
    data[f'Pixel f{which_pixel} Forward J'],
    color=colours[0],
    linewidth=1,
    label='Forward',
)
plt.plot(
    data[f'Pixel {which_pixel} Reverse V'],
    data[f'Pixel f{which_pixel} Reverse J'],
    '--',
    color=colours[0],
    linewidth=1,
    label='Reverse',
)

# You can change the code below to change the appearance and scale of your graph
# Possible changes can be found in the matplotlib library
plt.axvline(x=0, color='black', linewidth=0.5)
plt.axhline(y=0, color='black', linewidth=0.5)
plt.xlabel('Voltage (V)')
plt.ylabel('Current Density (mA/$cm^{2}$)')
plt.legend(loc=0)
plt.show()

This section of code will produce a graph like the one below.

Python J-V plot of an individual pixel
Python J-V plot of an individual pixel

Alternatively, you can use this code to plot the J-V sweep for every pixel on a device.

#%%
# This code will plot the J-V sweep for all pixels on your device 

# Plotting each pixel
# If not defining colours, remove "color=colours[i - 1]"
for i in range(1, number_of_pixels + 1):
    plt.plot(
        data[f'Pixel {i} Forward V'],
        data[f'Pixel {i} Forward J'],
        color=colours[i - 1],
        linewidth=1,
        label=f'Pixel {i} Forward',
    )
    plt.plot(
        data[f'Pixel {i} Reverse V'],
        data[f'Pixel {i} Reverse J'],
        '--',
        color=colours[i - 1],
        linewidth=1,
        label=f'Pixel {i} Forward',
    )

# You can change the code below to change the appearance and scale of your graph
# Possible changes can be found in the matplotlib library
plt.axvline(x=0, color='black', linewidth=0.5)
plt.axhline(y=0, color='black', linewidth=0.5)
plt.xlim(-0.1, 1.2)
plt.ylim(-25, 35)
plt.xlabel('Voltage (V)')
plt.ylabel('Current Density (mA/$cm^{2}$)')
plt.legend(loc=0)
plt.legend(ncol=2)
plt.show()
Current-voltage curve for a given device
J-V plot for each pixel on a given device

Solar Cell Testing Kit

  • Class AAA
  • Easy Solar Cell Characterisation
  • Unbeatable Value

Available From £3800

Module List


Details and licensing information on of the modules used in this code is provided below.

Matplotlib

Matplotlib is a library that is used in Python to easily create a display various forms of charts and graphs. Plotting is as simple as calling plot(x_values, y_values) in most cases. More can be seen in our tutorials on matplotlib.

Show license notice

Can be found at http://matplotlib.org/users/license.html.

  1. This LICENSE AGREEMENT is between the Matplotlib Development Team (“MDT”), and the Individual or Organization (“Licensee”) accessing and otherwise using matplotlib software in source or binary form and its associated documentation.
  2. Subject to the terms and conditions of this License Agreement, MDT hereby grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce, analyze, test, perform and/or display publicly, prepare derivative works, distribute, and otherwise use matplotlib 1.5.3 alone or in any derivative version, provided, however, that MDT’s License Agreement and MDT’s notice of copyright, i.e., “Copyright (c) 2012–2013 Matplotlib Development Team; All Rights Reserved” are retained in matplotlib 1.5.3 alone or in any derivative version prepared by Licensee.
  3. In the event Licensee prepares a derivative work that is based on or incorporates matplotlib 1.5.3 or any part thereof, and wants to make the derivative work available to others as provided herein, then Licensee hereby agrees to include in any such work a brief summary of the changes made to matplotlib 1.5.3.
  4. MDT is making matplotlib 1.5.3 available to Licensee on an “AS IS” basis. MDT MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, MDT MAKES NO AND DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF MATPLOTLIB 1.5.3 WILL NOT INFRINGE ANY THIRD PARTY RIGHTS.
  5. MDT SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF MATPLOTLIB 1.5.3 FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING MATPLOTLIB 1.5.3, OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
  6. This License Agreement will automatically terminate upon a material breach of its terms and conditions.
  7. Nothing in this License Agreement shall be deemed to create any relationship of agency, partnership, or joint venture between MDT and Licensee. This License Agreement does not grant permission to use MDT trademarks or trade name in a trademark sense to endorse or promote products or services of Licensee, or any third party.
  8. By copying, installing or otherwise using matplotlib 1.5.3, Licensee agrees to be bound by the terms and conditions of this License Agreement.

Pandas

Pandas is a python package that simplifies working with "labelled" or "relational" data, making real-world data analysis faster and easier. Processing files using DataFrames can make data handling, plotting, and analyzing uncomplicated and simple.

Show license notice

BSD 3-Clause License

Copyright (c) 2008-2011, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team All rights reserved.

Copyright (c) 2011-2022, Open source contributors.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
  •  

    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

    Contributing Authors


    Written by

    Dr. Mary O'Kane

    Application Scientist

    Return to the top