# 创建金字塔图 > ggplot(summary_data, aes(x = reorder(WklyStudyHours, ifelse(Gender == "female", AvgTotalScore, -AvgTotalScore)), y = AvgTotalScore)) + + geom_bar(stat = "identity", aes(fill = Gender), width = 0.5) + + scale_fill_manual(values = c("pink", "blue")) + + theme_bw() + + labs(x = "WklyStudyHours", y = "AvgTotalScore") + + coord_flip() + + geom_segment(aes(x = 0, xend = 0, y = min(summary_data$AvgTotalScore), yend = max(summary_data$AvgTotalScore)), color = "black", linetype = "dashed") + + scale_x_continuous(breaks = c(-300, 0, 300), labels = abs(c(-300, 0, 300))) Error: Discrete value supplied to continuous scale
时间: 2024-04-26 16:21:26 浏览: 158
这个错误提示意味着您在使用 `scale_x_continuous()` 函数时,将离散值传递给了连续的比例尺。您需要检查您传递给 `scale_x_continuous()` 函数的参数,确保这些参数是连续的值。可能原因是您传递给 `scale_x_continuous()` 函数的 `breaks` 参数中包含了离散值。您可以修改这些离散值为连续的值,或者将 `scale_x_discrete()` 函数替换为 `scale_x_continuous()` 函数。如果您需要更多帮助,请提供更多关于您的数据和代码的上下文。
相关问题
我要把feature_type_mean放在横轴其他位置,请增加代码,#这种初始化操作可以用来创建一个空的数据结构,用于后续存储和填充数据。在这种情况下,DataFrame的所有元素被初始化为0,准备接收进一步的数据填充。 filter_features = pd.DataFrame(0, index=filter_names, columns=feature_type_names, ) for key in c: for filter_name in filter_names: for feature_type_name in feature_type_names: if filter_name in key and feature_type_name in key: # print(filter_name, feature_type_name, key, c[key]) filter_features.loc[filter_name, feature_type_name] += c[key] filter_features['filter_mean'] = filter_features.mean(axis = 1) filter_features.loc['feature_type_mean'] = filter_features.mean(axis = 0) # %% plt.figure(figsize=(8, 12), dpi=300) sns.set_style('white', {'font.sans-serif': ['simsun', 'Times New Roman'], "size": 6}) ax = sns.heatmap(filter_features, # .apply(np.log1p), #vmin=5, vmax=17, fmt=".3f", annot=False, cmap="YlOrBr",#"vlag",#"YlOrBr", # cmap="RdBu_r", annot_kws={"size": 6}, square=True ) # label_y = ax.get_yticklabels() # plt.setp(label_y, rotation=45) # label_x = ax.get_xticklabels() # plt.setp(label_x, rotation=45) # plt.tick_params(labelsize=6) plt.show()
To move the 'feature_type_mean' column to a different position in the DataFrame, you can use the `reindex` method of pandas DataFrame. Here's the modified code:
```
filter_features = pd.DataFrame(0, index=filter_names, columns=feature_type_names)
for key in c:
for filter_name in filter_names:
for feature_type_name in feature_type_names:
if filter_name in key and feature_type_name in key:
filter_features.loc[filter_name, feature_type_name] += c[key]
filter_features['filter_mean'] = filter_features.mean(axis=1)
# Calculate the mean of each column and store it in a new DataFrame
feature_type_mean = filter_features.mean(axis=0)
feature_type_mean_df = pd.DataFrame(feature_type_mean, columns=['feature_type_mean'])
# Reorder the columns in the DataFrame
filter_features = pd.concat([feature_type_mean_df, filter_features.drop(columns=['feature_type_mean'])], axis=1)
plt.figure(figsize=(8, 12), dpi=300)
sns.set_style('white', {'font.sans-serif': ['simsun', 'Times New Roman'], "size": 6})
ax = sns.heatmap(filter_features, fmt=".3f", annot=False, cmap="YlOrBr", annot_kws={"size": 6}, square=True)
plt.show()
```
In this modified code, the `feature_type_mean` column is calculated separately and stored in a new DataFrame `feature_type_mean_df`. Then, the `concat()` method is used to combine this DataFrame with the original `filter_features` DataFrame, but with the columns reordered. Finally, the heatmap is plotted using the modified `filter_features` DataFrame.
FAILED: CMakeFiles/cartographer.transform.timestamped_transform_test.dir/cartographer/transform/timestamped_transform_test.cc.o /usr/bin/c++ -DBOOST_ALL_NO_LIB -DBOOST_IOSTREAMS_DYN_LINK -DGFLAGS_IS_A_DLL=0 -I../cartographer -I. -I../ -isystem /usr/include/eigen3 -isystem /usr/include/lua5.2 -O3 -DNDEBUG -pthread -fPIC -Wall -Wpedantic -Werror=format-security -Werror=missing-braces -Werror=reorder -Werror=return-type -Werror=switch -Werror=uninitialized -O3 -DNDEBUG -pthread -fPIC -Wall -Wpedantic -Werror=format-security -Werror=missing-braces -Werror=reorder -Werror=return-type -Werror=switch -Werror=uninitialized -O3 -DNDEBUG -std=gnu++11 -MD -MT CMakeFiles/cartographer.transform.timestamped_transform_test.dir/cartographer/transform/timestamped_transform_test.cc.o -MF CMakeFiles/cartographer.transform.timestamped_transform_test.dir/cartographer/transform/timestamped_transform_test.cc.o.d -o CMakeFiles/cartographer.transform.timestamped_transform_test.dir/cartographer/transform/timestamped_transform_test.cc.o -c ../cartographer/transform/timestamped_transform_test.cc In file included from ../cartographer/transform/timestamped_transform_test.cc:17: ../cartographer/transform/timestamped_transform.h:21:10: fatal error: cartographer/transform/proto/timestamped_transform.pb.h: No such file or directory 21 | #include "cartographer/transform/proto/timestamped_transform.pb.h" | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ compilation terminated. [44/380] Building CXX object CMakeFiles/cartographer.sensor.internal.voxel_filter_test.dir/cartographer/sensor/internal/voxel_filter_test.cc.o
根据你提供的错误信息,看起来是在编译过程中发生了一个错误。错误信息显示,在 `timestamped_transform_test.cc` 文件中的第17行引入的头文件 `cartographer/transform/timestamped_transform.h` 中,包含的另一个头文件 `cartographer/transform/proto/timestamped_transform.pb.h` 找不到。这可能是由于缺少相关的依赖或者路径配置错误导致的。
解决这个问题的方法是确保你已经正确安装了所需的依赖,并且在编译过程中正确设置了头文件搜索路径。你可以检查一下你的编译环境是否配置正确,特别是与 Cartographer 相关的依赖和头文件路径。另外,还可以确认一下是否有缺少其他必需的文件或库。
如果问题仍然存在,请提供更多关于你的编译环境和相关配置的信息,以便我能够更好地帮助你解决问题。
阅读全文