<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Chapter 3 :: Coding For Chemists</title>
    <link>https://codingforchemistsbook.com/book_material/chapter-3/index.html</link>
    <description>Data Download Data for Chapter 3&#xA;Alternatively, individual files can be found in the Data section.&#xA;Code from chapter &#39;&#39;&#39; A program to plot multiple uv-vis spectra from .csv files from a titration experiment Requires: .csv files with col 1 as wavelength and col 2 as intensity Written by: Ben Lear and Chris Johnson (authors@codechembook.com) v1.0.0 - 250131 - initial version &#39;&#39;&#39; import numpy as np from plotly.subplots import make_subplots from codechembook.quickTools import quickOpenFilenames # First, we need the names of the files that we want to plot # Ask the user to select the files and then sort the resulting list data_files = quickOpenFilenames(filetypes = &#39;CSV files, *.csv&#39;) sorted_data_files = sorted(data_files) # Next, we will process one file at a time and add it to the plot titration_series = make_subplots() # start a blank plotly figure object # Read the data in one file and add it as a scatter trace to the figure object for file in sorted_data_files: # loop through the data files one at a time # Read the data and store it in temporary x and y variables x_data, y_data = np.genfromtxt(file, delimiter = &#39;,&#39;, skip_header = 1, unpack = True) # Add data as scatter trace with formatted lines and exclude from legend titration_series.add_scatter(x = x_data, y = y_data, line = dict(color = &#39;gray&#39;, width = 1, dash = &#39;dot&#39;), name = file.stem + &#39; eqs&#39;, showlegend=False) # Adjust the appearance of only the first and last traces to highlight titration_series.update_traces(selector = 0, # specify the initial trace line = dict(color = &#39;darkcyan&#39;, width = 2, dash = &#39;solid&#39;), showlegend = True, name = &#39;initial&#39;) titration_series.update_traces(selector = -1, # specify the final trace line = dict(color = &#39;darkred&#39;, width = 2, dash = &#39;solid&#39;), showlegend = True, name = &#39;final&#39;) # Move the initial trace to the end of the data, so that it is drawn on top titration_series.data = titration_series.data[1:] + titration_series.data[:1] # Format the plot area and then show it and then save it titration_series.update_layout(template = &#39;simple_white&#39;) titration_series.update_xaxes(title = &#39;wavelength /nm&#39;, range = [270, 1100]) titration_series.update_yaxes(title = &#39;absorbance&#39;, range = [0, 4.5]) titration_series.show(&#39;png+browser&#39;) titration_series.write_image(&#39;titration.png&#39;, width = 3*300, height = 2*300) Solutions to Exercises Targeted exercises Making ordered collections of data more flexible using list objects Exercise 0 Make a list that contains no items.</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <managingEditor>authors@codingforchemistsbook.com (Benjamin Lear and Christopher Johnson)</managingEditor>
    <webMaster>authors@codingforchemistsbook.com (Benjamin Lear and Christopher Johnson)</webMaster>
    <atom:link href="https://codingforchemistsbook.com/book_material/chapter-3/index.xml" rel="self" type="application/rss+xml" />
  </channel>
</rss>