This is simply a practice exercise to see if I could create the $StarTrek^\circledR$ - Medical Dashboard using MatPlotLib. Currently it's incomplete but seems doable in MatPlotLib.

In [1]:
# set up the imports
import numpy as np
from matplotlib import ticker
import matplotlib.pyplot as plt
In [2]:
%matplotlib inline
# Configure figure size and DPI for screen demo
plt.rcParams['figure.figsize'] = (7,3)
plt.rcParams['figure.dpi'] = 150

MatPlotLib Figure Object

Top level view

title

title

In [3]:
# get the black background
# plt.style.use('dark_background')
# What styles are available.
plt.style.available
Out[3]:
['classic',
 'seaborn-white',
 'bmh',
 'seaborn-dark-palette',
 'seaborn-muted',
 'seaborn-dark',
 'seaborn-paper',
 'seaborn-colorblind',
 'seaborn-ticks',
 'dark_background',
 'seaborn-poster',
 'fast',
 'seaborn-bright',
 'seaborn-pastel',
 'seaborn-deep',
 'seaborn',
 'seaborn-notebook',
 'seaborn-talk',
 '_classic_test',
 'grayscale',
 'seaborn-darkgrid',
 'fivethirtyeight',
 'seaborn-whitegrid',
 'Solarize_Light2',
 'ggplot']
In [4]:
# Generate all the values for the major ticks
temp_ticks = list(range(93,105))
brain_ticks = list(range(0,150,10))
lung_ticks = list(range(0,40,5))
# use numpy instead of straight python
cell_ticks = np.arange(20,70,10)
blood_syst_ticks = np.arange(0,260,20)
blood_dias_ticks = np.arange(0,150,10)

tempF = '$<98.6$'
brain_val ='$<101%$'
In [5]:
# Function to remove spines from the axes
def remove_spines(ax):
    ax.spines['left'].set_visible(False)
    ax.spines['right'].set_visible(False)
    ax.spines['bottom'].set_visible(False)
    ax.spines['top'].set_visible(False)
In [6]:
# set up the top level figure
fig = plt.figure()
<matplotlib.figure.Figure at 0x7f64c8975ef0>
In [7]:
# Set up the temp bar
fig = plt.figure()
ax1 = fig.add_subplot(161)                        # 1 row, 6 columns, subplot #1

ax1.plot(.6,98.6, 'r<', marker=tempF, markersize=20)             #  red triangle(<) with size of 20          
# ax1.set_ylim((temp_ticks[0], temp_ticks[-1]))    # doesn't work- soemthing to do with plots not static???
ax1.set_yticks(range(temp_ticks[0], temp_ticks[-1]))
ax1.set_xlim((0,1))
ax1.set_xticks([])
ax1.axhspan(93,96, xmin=0, xmax= 0.3, facecolor= 'r', alpha = 0.8)       # add the axes background colors
ax1.axhspan(100,104, xmin=0, xmax= 0.3, facecolor = 'r', alpha = 0.8)
ax1.axhspan(96,100, xmin=0, xmax= 0.3, facecolor = 'darkorange', alpha = .8)
ax1.axhspan(98.5, 98.7, xmin=0, xmax= 0.3,facecolor = 'g', alpha = 1)
ax1.set_xlabel('TEMP\nF', horizontalalignment='right')            # Set the label at the bottom
Out[7]:
Text(0.5,0,'TEMP\nF')
In [8]:
# set up the brain bar
ax2 = plt.subplot(162)                                        # create a plot 1 row, 6 cols, plot 1
ax2.plot(0.6,101,'r<', marker=brain_val, markersize=20)
# ax2.set_ylim(brain_ticks[0], brain_ticks[-1])                      # set the major tick limits
ax2.set_yticks(brain_ticks)
ax2.set_xlim((0,1))                                                    # show the major tick values
ax2.set_xticks([])                                                      # Remove the X Ticks
plt.axhspan(0,52, xmin=0, xmax= 0.3, facecolor= 'r', alpha = 0.8)       # add the axes background colors
plt.axhspan(93,140, xmin=0, xmax= 0.3, facecolor = 'r', alpha = 0.8)
plt.axhspan(52,93, xmin=0, xmax= 0.3, facecolor = 'darkorange', alpha = .8)
plt.axhspan(60, 85, xmin=0, xmax= 0.3,facecolor = 'g', alpha = 1)
plt.xlabel('Brain')            # Set the label at the bottom
Out[8]:
Text(0.5,0,'Brain')
In [9]:
# add the rest of the bars 
plt.subplot(162)
plt.ylim(brain_ticks[0], brain_ticks[-1])
plt.tight_layout()  # moves the bars furthur apart
plt.subplot(163)
plt.ylim(lung_ticks[0], lung_ticks[-1])
plt.subplot(164)
plt.ylim(cell_ticks[0], cell_ticks[-1])
plt.subplot(165)
plt.ylim(blood_syst_ticks[0], blood_syst_ticks[-1])
plt.subplot(166)
plt.ylim(blood_dias_ticks[0], blood_dias_ticks[-1])
Out[9]:
(0, 140)
In [ ]:
 
In [10]:
# start to put it all together

plt.style.use('dark_background')
fig2 = plt.figure()
plt.tight_layout()
plt.figtext(0.5, 1.1, '$StarTrek^\circledR - Medical Dashboard$', fontsize='xx-large', fontweight='bold',
            horizontalalignment="center")

ax1 = fig2.add_subplot(171)
ax1.plot(.6,98.6, 'g<', markersize='15')
# ax1.set_ylim((temp_ticks[0], temp_ticks[-1]))
ax1.set_yticks(temp_ticks)
ax1.set_xlim((0,1))
ax1.set_xticks([])
remove_spines(ax1)
ax1.axhspan(93,96, xmin=0, xmax= 0.3, facecolor= 'r', alpha = 0.8)       # add the axes background colors
ax1.axhspan(100,104, xmin=0, xmax= 0.3, facecolor = 'r', alpha = 0.8)
ax1.axhspan(96,100, xmin=0, xmax= 0.3, facecolor = 'darkorange', alpha = .8)
ax1.axhspan(98.5, 98.7, xmin=0, xmax= 0.34,facecolor = 'g', alpha = 1)
ax1.set_xlabel('TEMP\nF', horizontalalignment='right')            # Set the label at the bottom

ax2 = fig2.add_subplot(172)
ax2.plot(.6, 101,'r<', markersize='15')
# ax2.ylim(brain_ticks[0], brain_ticks[-1])       # set the major tick limits
ax2.set_yticks(brain_ticks)                        # show the major tick values
ax2.set_xlim(0,1)
ax2.set_xticks([])                                # Remove the X Ticks
remove_spines(ax2)
ax2.axhspan(0,52, xmin=0, xmax= 0.3, facecolor= 'r', alpha = 0.8)       # add the axes background colors
ax2.axhspan(93,140, xmin=0, xmax= 0.3, facecolor = 'r', alpha = 0.8)
ax2.axhspan(52,93, xmin=0, xmax= 0.3, facecolor = 'darkorange', alpha = .8)
ax2.axhspan(60, 85, xmin=0, xmax= 0.34,facecolor = 'g', alpha = 1)
ax2.set_xlabel('Brain', horizontalalignment='right')            # Set the label at the bottom

# create the rest of the bars
ax3 = fig2.add_subplot(173)
ax3.plot(.6, 17.3,'r<', markersize='15')
# ax3.ylim(brain_ticks[0], brain_ticks[-1])       # set the major tick limits
ax3.set_yticks(lung_ticks)                        # show the major tick values
ax3.set_xlim(0,1)
ax3.set_xticks([])                                # Remove the X Ticks
remove_spines(ax3)
ax3.axhspan(0,11.5, xmin=0, xmax= 0.3, facecolor= 'r', alpha = 0.8)       # add the axes background colors
ax3.axhspan(25,35, xmin=0, xmax= 0.3, facecolor = 'r', alpha = 0.8)
ax3.axhspan(11.5,25, xmin=0, xmax= 0.3, facecolor = 'darkorange', alpha = .8)
ax3.axhspan(16, 21.5, xmin=0, xmax= 0.34,facecolor = 'g', alpha = 1)
ax3.set_xlabel('Lungs', horizontalalignment='right')            # Set the label at the bottom

ax4 = fig2.add_subplot((174))
#ax4.tick_params(axis='y',          # changes apply to the x-axis
#               which='both',      # both major and minor ticks are affected
#               left='off',      # ticks along the bottom edge are off
#                right='off',         # ticks along the top edge are off
#                labelleft='off')

ax4.tick_params(axis='x',          # changes apply to the x-axis
                which='both',      # both major and minor ticks are affected
                bottom='off',      # ticks along the bottom edge are off
                top='off',         # ticks along the top edge are off
                labelbottom='off')

ax4.plot(0,0.85, 'go', markersize='30')
ax4.plot(0,0.55, 'go', markersize='30')
ax4.set_ylim(0,1)
ax4.set_xticks([])
ax4.set_yticks([])
remove_spines(ax4)

plt.tight_layout()

ax5= fig2.add_subplot(175)
ax5.set_ylim(lung_ticks[0], lung_ticks[-1])
ax6 = fig2.add_subplot(176)
ax6.set_ylim(cell_ticks[0], cell_ticks[-1])
ax7 = fig2.add_subplot(177)
ax7.set_ylim(blood_syst_ticks[0], blood_syst_ticks[-1])
Out[10]:
(0, 240)
In [ ]:
 
In [ ]:
 
In [ ]:
 
In [ ]: