0

I have a series of data [frequency, intensity] measured at different temperatures. I would like to plot this so that the frequency data is on the x axis, the temperature is the y axis, and the colour shows the intensity. Each temperature would then form a horizontal line at the corresponding temperature.

For the sake of a MWI that is similar to my data, we can imagine that a noisy signal is measured at three different temperatures:

import pandas as pd
import numpy as np; np.random.seed(1)

# columns for x and three temperatures
columns=['x','275 K','300 k','325 K']
# linear x
x=np.linspace(-5,5)
# random noise
noise=np.random.randn(3,len(x))
df=pd.DataFrame(np.vstack((x,noise)).T,columns=T)

The aim is to produce something similar to this 1D heatmap, but with several stacked flat lines, preferably with the y-position corresponding to the measured temperature. If this is not practicable, then I can simply add a label indicating the temperature.

ARGratrex
  • 73
  • 5
  • 1
    Does this answer your question? [Generate a heatmap in Python with xyz dataframe](https://stackoverflow.com/questions/43993864/generate-a-heatmap-in-python-with-xyz-dataframe?noredirect=1&lq=1) Or this one, where data is of different shapes? [Drawing heat map in python](https://stackoverflow.com/questions/41962146/drawing-heat-map-in-python) – AJ Biffl Nov 23 '21 at 19:12
  • Not really, as those answers assume a continuum of y-values. I am looking for something closer to [this](https://matplotlib.org/stable/gallery/lines_bars_and_markers/multicolored_line.html#sphx-glr-gallery-lines-bars-and-markers-multicolored-line-py), where I can simply set the y-axis to be a constant value. I added 'heatmap' to the tags as it's a well-known use of colour as intensity, but it's not quite what I'm after. – ARGratrex Nov 24 '21 at 11:20
  • [This](https://stackoverflow.com/a/56003476/15580943) looks promising. Will attempt after lunch. – ARGratrex Nov 24 '21 at 11:31

0 Answers0