I have a matrix consisting of 5 columns. The first and second columns are for x_start & y_start of the line, the third and fourth are for x_end & y_end. The fifth is -concentration of contaminant in this line- giving the value for the color of my graph. I want to plot x_start & y_start with x_end & y_end for each line and give this line a color based on the value of concentration which is ranging in color from Cmin to Cmax within a colormap. Any help?
相关问题
- Extract matrix elements using a vector of column i
- Plotting multiple columns with ggplot2 [duplicate]
- How do you get R's null and residual deviance
- R markov chain package, is possible to set the coo
- How to display an image represented by three matri
相关文章
- How to plot smoother curves in R
- How to add clipboard support to Matplotlib figures
- Adding a legend to a matplotlib boxplot with multi
- How do I append metadata to an image in Matlab?
- How can I write-protect the Matlab language?
- `std::sin` is wrong in the last bit
- Escape sequence to display apostrophe in MATLAB
- R plot legend with transparent background
I hope I've understood your question correctly. You can try the following code. Assuming your data is in the following format:
and you use one of the matlab colormaps
Based on a minimum and maximum concentration (first and last value of the colormap) you can calculated to indices of the colors by
and overwrite the
ColorOrder
of the graph withand do the plot with
EDIT: To display the correct colorbar, just add
My approach which is not fully automated (if you expected something like this) would go:
concentration of contaminant
meaning the min and max value.To give an example:
I usually prefer a combined scheme with varying line style, point style and color
So if a sample falls into 1st bin (imagine
i = 1
) I will do something like:and since you have a random combination of lines, points and colors the different lines you get are 2*7*5 = 70. Of course you can change the combinations.
I guess maybe @Nemesis's solution might be more elegant but this one gives direct control on some parameters and that's why I provide it.
P.S. I use only these colors because other like cyan ('c') or yellow ('y') do not show really well.