Preferences偏好设置-Colors
3、Colors:可以用来更改unity软件的窗口颜色
颜色
此面板允许您选择Unity在显示各种用户界面元素时使用的颜色。
Colors 颜色
This panel allows you to choose the colors that Unity uses when displaying various user interface elements.
这个面板让你选择颜色来修改界面元素的颜色。
# 需要导入模块: from matplotlib import colors [as 别名]
# 或者: from matplotlib.colors import BASE_COLORS [as 别名]
def draw_embedding(embs, names, resultpath, algos, show_label):
"""Function to draw the embedding.
Args:
embs (matrix): Two dimesnional embeddings.
names (list):List of string name.
resultpath (str):Path where the result will be save.
algos (str): Name of the algorithms which generated the algorithm.
show_label (bool): If True, prints the string names of the entities and relations.
"""
pos = {}
node_color_mp = {}
unique_ent = set(names)
colors = list(dict(mcolors.BASE_COLORS, **mcolors.CSS4_COLORS).keys())
tot_col = len(colors)
j = 0
for i, e in enumerate(unique_ent):
node_color_mp[e] = colors[j]
j += 1
if j >= tot_col:
j = 0
G = nx.Graph()
hm_ent = {}
for i, ent in enumerate(names):
hm_ent[i] = ent
G.add_node(i)
pos[i] = embs[i]
colors = []
for n in list(G.nodes):
colors.append(node_color_mp[hm_ent[n]])
plt.figure()
nodes_draw = nx.draw_networkx_nodes(G,
pos,
node_color=colors,
node_size=50)
nodes_draw.set_edgecolor('k')
if show_label:
nx.draw_networkx_labels(G, pos, font_size=8)
if not os.path.exists(resultpath):
os.mkdir(resultpath)
files = os.listdir(resultpath)
file_no = len(
[c for c in files if algos + '_embedding_plot' in c])
filename = algos + '_embedding_plot_' + str(file_no) + '.png'
plt.savefig(str(resultpath / filename), bbox_inches='tight', dpi=300)
# plt.show()
Sort Colors
Given an array with n objects colored red, white or blue, sort them in-place so that objects of the same color are adjacent, with the colors in the order red, white and blue.
Here, we will use the integers 0, 1, and 2 to represent the color red, white, and blue respectively.
Note: You are not suppose to use the library’s sort function for this problem.Example
Input: [2,0,2,1,1,0]
Output: [0,0,1,1,2,2]Solution
@允许两次遍历的话就直接对0、1、2计数再依次填充即可,一次遍历设定双指针 class Solution: def sortColors(self, nums: List[int]) -> None: """ Do not return anything, modify nums in-place instead. """ if nums==[]: return nums p1 = 0 p2 = len(nums)-1 i = 0 while i<=p2: if nums[i]==2: nums[i], nums[p2] = nums[p2], 2 p2 -= 1 elif nums[i]==0: nums[i], nums[p1] = nums[p1], 0 p1 += 1 i += 1 else: i += 1