1
$\begingroup$

I am planning to use python to get a plot like this enter image description here.

But, I am only able to get this, enter image description here

So, I would appreciate it if someone helps me with this issue, (Maybe how to format the data): How to have lower X-axis values highlighted like in the original plot.

Please check the code below and looking forward to your suggestions. Numpy and Matplotlib are being used.

    x = [192, 188/4, 168/24, 144/48, 96/96]
    ys = [[2.20, 0.758, 0.691], [1.44, 0.708, 0.733], [0.491, 0.379, 0.440], [0.349, 0.350, 0.165], [0.199, 0.157, 0.163]]
    
    print(len(x), len(ys))
    colors = [["r", "y", "g"], ["r", "y", "g"], ["r", "y", "g"], ["r", "y", "g"], ["r", "y", "g"]]
    print(colors)
    
    for y, x, c in zip(ys, x, colors):
    #     print(y, [x])
    #     print([x]*len(y))
        plt.scatter([x]*len(y), y, color = c)    
        
    
    plt.xticks([192, 188/4, 168/24, 144/48, 96/96])
    plt.xlabel("Si/Al Ratio")
    plt.ylabel("Diff Coeff (Ang**2)")
    # plt.legend(['Water_Cubic{}'.format(i) for i in [12, 24, 48]], loc=2, bbox_to_anchor=(1.05, 1), borderaxespad=0., fontsize=11)
    plt.title("Si/Al vs Diff Coeff at 300k for Water Content (12, 24, 48)")
$\endgroup$
7
  • 2
    $\begingroup$ I'm maybe not understanding the question. I don't see any highlighted values in the upper plot. Do you just want different values for the xticks? You are setting these manually, so you can either specify a different set of these or let matplotlib set them automatically based on your x values. $\endgroup$
    – Tyberius
    Commented Jul 13, 2022 at 12:30
  • 2
    $\begingroup$ This question is not related to Materials modeling and instead should be asked on e.g. StackOverflow. $\endgroup$ Commented Jul 19, 2022 at 22:44
  • $\begingroup$ @PeterSchindler it was asked on SO: stackoverflow.com/q/72959365/1271772 $\endgroup$ Commented Jul 21, 2022 at 14:36
  • 2
    $\begingroup$ This was both asked and answered on SO around the same time as you asked the question here. Please refrain from cross posting questions on multiple SE, as this makes it difficult for users to know where else a question has been asked and leads to duplicated effort when providing answers. At a minimum, you should include a link to any alternate versions of your question on other sites. $\endgroup$
    – Tyberius
    Commented Jul 21, 2022 at 17:35
  • 1
    $\begingroup$ @B.Kelly What plotting library can? $\endgroup$
    – Anyon
    Commented Jul 23, 2022 at 0:11

1 Answer 1

2
$\begingroup$

It is very unclear what you are asking about. "How to have lower X-axis values highlighted like in the original plot."

There is no x-axis highlighting in any of the plots.

I tried to convert your data into a plot that looks a lot like the one you aimed for, here is my best guess:

enter image description here

The code used to generate the plot can be found at https://github.com/erikkjellgren/Shared_scripts/blob/main/notebooks/sial_plot.ipynb

$\endgroup$
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .