Change layout shape label dynamically?

I have a Plotly layout with one shape added which works fine (see Layout.shapes in JavaScript ). The shape is a line with a label. Now I want to update the label text in Javascript. As a new user of Plotly, I have no idea how to do this. Any help greatly appreciated.

My layout definition is:

    "layout": {
		title: 'Sensor 1',
        "xaxis": {
            "type": "linear",
            "title":  "Time (s)",
			"autosize": false, width: 1200, height:400
            "autorange": true,
            "rangeslider": {
                "range": [
                "yaxis": {
                    "rangemode": "match"
                "visible": true,
                "autorange": true
        "yaxis": {
            "type": "linear",
            "autorange": true
	shapes: [{
		type: 'line',
		xref: 'paper',
		x0: 0.5,
		x1: 0.5,
		yref: 'paper',
		y1: 1,
		label: {text: "XYZ123", textposition: 'end', textangle: '0'},
		line: {
			color: 'red',
			width: 1,
			dash: 'dot'

Can you clarify a bit how you’re wanting to update the label text? I assume, you wish to do so dynamically? If so, explain the scenario. Of course you can revise “XYZ123” however you wish, directly. But if you clarify it will help me understand how to respond.