1

I have a problem with graphs that has much more lines than one, but they all has to be on one graph(they are measured together). As a result i have to create multiple layer pdf so that person that will read this pdf can turn on/off all the graphs lines separately. Most of pdf readers are capable of layer recognition. Is there any way to create multi layer pdf from matplotlib?

Layer 1: everything but lines on graphs(text, axis, grids, pictures, legend) Layer 2: 1st measurement ... Layer 4: nth measurement

Example code to work with:

import matplotlib.pyplot as plt
import random

# Generate random data for 5 lines
data = []
for i in range(5):
    x = [j for j in range(10)]
    y = [random.random() for j in range(10)]
    data.append((x, y))

# Plot the lines
for x, y in data:
    plt.plot(x, y)

# Show the plot
plt.savefig("graph.pdf")
plt.show()

Expected result: pdf file with multiple layers.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.