Code Monkey home page Code Monkey logo

vf_pyplot's Introduction

24-2 Visual Field Plot

This is a brief overview describing how to generate a 24-2 visual field plot.

# Import packages
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline

First let us import a table that maps (x, y) coordinates to (i, j) coordinates.

vf_map = pd.read_csv('./vf_map.csv')

Now we will use this table to determine where to plot.

In this example I will plot dummy data. To plot your data, you can either:

  1. Join the vf_map to your data (on the x and y variables) then subset your data by i and j within the for loop
  2. Extract the x and y coordinates from the vf_map at each iteration of the for loop then subset your data based on these values.
# Define subplot
fig, ax = plt.subplots(8, 9, sharex='col', sharey='row', figsize=(18, 14))

# Loop through rows and columns
for i in range(8):
    for j in range(9):
        # Check subplot coordinates against vf_map coordinates
        loc = (vf_map.i == i) & (vf_map.j == j)
        
        # Generate plot if coordinates are present, otherwise remove the subplot
        if any(loc):
            # Change these values
            data = np.random.randn(500) # replace with your data
            bins = 30 # you can instead use np.arange(-1, 2, 0.1) for fixed-width bins
    
            # Plot
            ax[i,j].hist(data, bins = bins, color = '#1D4F91')    
            
            # Remove ticks and ylabel
            ax[i,j].tick_params(length = 0)
            ax[i,j].set_yticklabels([])
            
        else:
            ax[i,j].remove()
           
# # You can save the plot as follows:
# plt.savefig('tmp.png', dpi = 300) 

png

That's it!

We can adjust the spacing, add a title, save the plot, as desired.

vf_pyplot's People

Watchers

Nikhil Bommakanti avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.