Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6557609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:05:43+00:00 2026-05-25T13:05:43+00:00

I want to plot a triangular mesh, and color each edge with a different

  • 0

I want to plot a triangular mesh, and color each edge with a different color. The matlab documentation for trimesh states there’s a color argument, but it doesn’t state what its structure should be – as the triangles share edges, how do I know where to position which color inside the vector C?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T13:05:44+00:00Added an answer on May 25, 2026 at 1:05 pm

    I was struggling with this problem yesterday, and I think I have the solution. It turns out that in general if you want to be very detailed with which edge is which color, you have to be very sneaky.

    So you understand what the problem is, I’ll first review how the command trimesh(Tri,X,Y,Z,C) assigns colors in the first place. The argument C has be a vector of numbers with length equaling the number of vertices (not edges). The way it colors edges is as follows. If we have 4 vertices and we assign

    Tri=[1 2 3; 3 2 4]

    and

    C=[10 20 30 40]

    then the first edge found in Tri is 1 to 2 and it is colored using the color of point 1, which is 10. The next edge found is 2 to 3, which is colored using the color of point 2, which is 20. The next edge is 3 to 1, which has color 30. The next edge is 3 to 2 with color 30; notice this edge has already been colored 20 but this new color overwrites the old color. And then edge 2 to 4 is colored 20 and edge 4 to 3 is colored 40.

    The problem is that without using a special trick, this coloring scheme can make it literally impossible to color the edges exactly as you want. Your case in point: if you have more edges than vertices (as in my example) and you want each edge to be colored differently, you are out of luck because the edges are colored according to the colors assigned to the vertices. But if we make multiple copies of each vertex (and, consequently, multiple copies of each edge), then we are back in business. Also, our lives are made easier by the fact that Tri accepts not just faces but also individual edges as well.

    As an example of what I mean, suppose you wanted edge 2 to 3 to have the color 50 in the example above. To do this, make a new point, point 5, which is the same as point 2 (i.e., the same (x,y,z) coordinates). Redefine Tri and C as follows:

    Tri=[1 2 3; 3 2 4;3 5 3]

    C=[10 20 30 40 50]

    Notice that the last three numbers in Tri do not define a face but rather an edge (the edge 3 to 5, which is the same as 2 to 3). This edge will be colored by whatever color point 5 is assigned. In this manner, you can overwrite the colors of every edge individually. Just be sure to put these edges at the end of the Tri matrix so that their colorings overwrite any previous undesired colorings. If you don’t care about having faces filled in, you can even have a Tri matrix with nothing but edges. Its a bit of a hack, but it works.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to plot some confidence interval graphs in MATLAB but I don't have
I want to plot points, each with X, Y and a color. How do
I want to plot a graph which, for each edge in the dataset, will
I want to plot several curves, each having a different length. So, I've placed
I want to plot some data. The first column contains the x-data. But matplotlib
I want to plot a 3d graph in matlab By graph I mean in
I have 6 vectors which I want to plot. How I can make each
I want to plot data from different data frames with ggplot. However, I'm having
Ok, I can create a plot. But if I want the plot to be
I want to plot a series of lines with one half-space filled for each

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.