Click the Sample Line button again, then RMB to cancel - and the previous line will be gone.
If you want a button to directly remove it, edit the space_image.py script like shown below:
class IMAGE_PT_sample_line(Panel):
bl_space_type = 'IMAGE_EDITOR'
bl_region_type = 'PREVIEW'
bl_label = "Sample Line"
@classmethod
def poll(cls, context):
sima = context.space_data
return (sima and sima.image)
def draw(self, context):
layout = self.layout
sima = context.space_data
hist = sima.sample_histogram
# Add a remove button for sample line
split = layout.split(0.9, align=True)
split.operator("image.sample_line")
sub = layout.row()
sub.operator_context = 'EXEC_DEFAULT'
split.operator("image.sample_line", icon='X', text="")
layout.template_histogram(sima, "sample_histogram")
row = layout.row(align=True)
row.prop(hist, "mode", expand=True)
row.prop(hist, "show_line", text="")