-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path3D-Viab-Dose-Time.py
More file actions
57 lines (45 loc) · 1.26 KB
/
3D-Viab-Dose-Time.py
File metadata and controls
57 lines (45 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import pandas as pd
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
# Load data from CSV file
data = pd.read_csv('NEWum.csv')
#data = data[data['coumarinDose'] <= 200]
# Extract the relevant columns
time_hours = data['time']
dose = data['coumarinDose']
viability_percent = data['viability']
study_id = data['ID']
author = list(data['author'])
year = list(data['year'])
d = []
for i, j in zip(author, year):
xx = f"{i} {j}"
if xx not in d:
d.append(xx)
d = sorted(d)
# Create a 3D plot
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
# Create a colormap with enough colors
n_unique_study_ids = len(study_id.unique())
colors = plt.cm.viridis(np.linspace(0, 1, n_unique_study_ids))
# Scatter plot the data, color by study ID
for i, study_id_value in enumerate(study_id.unique()):
mask = study_id == study_id_value
ax.scatter(
time_hours[mask],
dose[mask],
viability_percent[mask],
c=[colors[i]],
marker='o',
label=f'{d[i]}'
)
# Set labels for the axes
ax.set_xlabel('Time (hours)')
ax.set_ylabel('Coumarin dose (μM)')
ax.set_zlabel('Viability (%)')
# Add a legend
ax.legend(loc='lower right', bbox_to_anchor=(1.5, 0.35))
# Show the 3D plot
plt.show()